
ZOJ Problem Set  2329
A circle formed by 'a' and 'b', you are required to figure out all such pairs of positions that when cutting the circle in a pair of the positions, we will get two segments that the number of 'a's in one segment is equal to the number of 'b's in the other segment. Input The length of circle: n is between 2 and 1000 inclusive. All the characters in the input is either 'a' or 'b'. There is no strings without any 'a' in the input. There is no strings without any 'b' in the input. Output There are no more than 400 test cases. For each test case, print out all the correct cuttings. For each cutting, print out a pair of integers, representing the two positions to cut on. In output, all the pairs of positions should be sorted. The llegal positions' number is between 0 and n1 inclusive. Print a blank line after each test case. Sample Input
ab Sample Output AB Circle #1: Note for sample 2 original:
baa BE CAREFULL: the total size of output might be very large.
Author: ZHENG, Jianqiang Source: ZOJ 3rd Anniversary Contest 