|시간 제한||메모리 제한||제출||정답||맞은 사람||정답 비율|
|2 초||512 MB||0||0||0||0.000%|
There are N charged particles, each with either a positive or a negative charge. The charge on each particle is unknown, but it is known that if two particles with the same charge are brought close together, they will repel each other and if two particles with a different charge are brought together, they will attract each other.
In an experiment, Q events happen in chronological order. Each event is of one of the following 2 types:
It is guaranteed that there is at least one configuration of particles that match all the experimental observations given.
Your program must read from standard input.
The input starts with a line with 2 integers, N and Q. N denotes the number of charged particles, Q denotes the number of events.
Q lines will then follow with 1 character and 2 integers each, the ith line will contain Ti, Ai and Bi. If Ti = ‘A’, it denotes type 1 event where particles Ai and Bi attract. If Ti = ‘R’, it denotes type 1 event where particles Ai and Bi repel. If Ti = ‘Q’, it denotes type 2 event asking whether particles Ai and Bi attract or repel (or either is possible).
Your program must print to standard output.
For every type 2 event, your program must output one line with one character. Output ‘A’ if the charges will attract, ‘R’ if the charges will repel, or ‘?’ if either is possible.
2 3 Q 1 2 R 1 2 Q 1 2
4 5 R 1 2 A 2 3 A 1 4 Q 2 4 Q 1 3