Home > Back-end >  Data structure, meet a problem, is there anyone any good ideas?
Data structure, meet a problem, is there anyone any good ideas?

Time:11-22

Description
To active classroom atmosphere, the teacher decided to play A little game with students, assuming that the teacher had A pocket A, B, C three ball, pulling out random N balls, existing the following rules: (1) any ball, A ball has A corresponding B and any B also has A corresponding A ball, (2) any ball on the left side of A ball must have the corresponding B (3) C have magic ball, can be turned into A ball or B, or directly take off, if the order in which A and B ball can be one-to-one correspondence (meet (1), (2), (3)), is A teacher, on the other hand, are classmates,

Enter
Input two lines, the first line is a positive integer N, enter a string, the second line of length N,

O
Output the teacher whether to win, is True, False said no,

The input sample
3
ABC
The output sample
True
Limit
1 n 10000 or less or less

Time: 2 SEC

Space: 256 MB

  • Related