시간 제한 | 메모리 제한 | 제출 | 정답 | 맞힌 사람 | 정답 비율 |
---|---|---|---|---|---|
1 초 | 128 MB | 5 | 0 | 0 | 0.000% |
"A Long Time Ago, in a Galaxy Far, Far Away..." one advanced civilization discovered a manner of instant traveling between solar systems. Since that moment, they have devoted all their efforts to constructing pairs of stargates that connect distant planets. Soon enough communication network became so complex that they require help to maintain information about the connected worlds.
Write a program that will help them maintain information about the connected systems and we will make sure that the best of your solutions will be forwarded to their space-time continuum. Planets A and B are connected if there is a direct stargate connection between them, or there is a planet sequence P1, P2, ..., Pn where P1=A, Pn=B and there is a direct stargate connection between Pk and Pk-1, k ∈ {2..n} . Connections are bidirectional. There can be multiple connection paths between two planets.
Input file consist of multiple data sets. Each data set occupies one or more lines. There are no empty lines in the input file. Each line starts with a single letter ‘D’, ‘C’ or ‘Q’ (upper or lower case) followed by 1 to 5 integers with following meaning:
Both ‘C’ and ‘Q’ command (‘X’ in following text) share the same syntax:
Example: X 1 100 3 creates following links (1,100), (1,101), (1,102).
Example: X 1 100 3 5 creates following links (1,100), (1,105), (1,110).
Example: X 1 100 3 5 15 creates following links (1,100), (16,105), (31,110).
Output file contains one line pre each query (‘Q’) line in the input file. Each line contains two numbers separated by space dash space sequence. First value represents number of connected planet pairs from appropriate query while second represents number of disconnected planet pairs.
d 5 C 1 3 D 20 q 1 3 c 1 10 10 Q 1 2 18 1 1
0 - 1 9 - 9
ICPC > Regionals > Europe > Southeastern European Regional Contest > SEERC 2006 F번