#P10734. [NOISG 2019 Prelim] Experimental Charges
[NOISG 2019 Prelim] Experimental Charges
Background
Translated from NOISG2019 Prelim C.Experimental Charges。
Problem Description
There are charged particles. A particle with a positive electron charge will attract a particle with a negative electron charge, while particles with the same electron charge will repel each other.
There are operations. Each operation is given as , and can be one of three types depending on :
- Operation
Ameans and attract each other. - Operation
Rmeans and repel each other. - Operation
Qasks, based on the information known so far, what would happen if and are placed together.
For each Q operation, if they attract each other, output A; if they repel each other, output R; if it cannot be determined, output ?.
It is guaranteed that there is at least one possibility such that all operations are consistent.
Input Format
The first line contains two integers .
The next lines each contain a character and two integers , describing an operation.
Output Format
Output several lines, each line being the answer to one Q operation.
2 3
Q 1 2
R 1 2
Q 1 2
?
R
4 5
R 1 2
A 2 3
A 1 4
Q 2 4
Q 1 3
A
A
Hint
Sample #1 Explanation
For the first query, the relationship between and cannot be determined, so output ?.
For the second query, it can be determined that and repel each other, so output R.
Constraints
| Score | |||
|---|---|---|---|
| None | |||
| None | or | ||
can only be R or Q |
|||
| Queries only appear after all relationships are given | |||
| None | |||
| None |
For of the testdata:
- can only be
A,R, orQ。
Translated by ChatGPT 5