-->
当前位置:首页 > 题库

PROGRAMMING:electronic communication

Luz5年前 (2021-05-10)题库431
There are n computers, numbered 1 to n. Set that if computer a and computer B can communicate, then computer B and computer a can also communicate; If computer a and computer B can communicate with each other, and computer B and computer C can communicate with each other, then computer a and computer C can also communicate with each other. Now given some computers can communicate, please write a program to determine whether any two computers can communicate.
###Input format:
Enter the first line of three integers, N, m and Q. N is the number of computers; M is the logarithm of the input communicable computer; Q is the number of queries. Next, m lines, each line contains two integers a and B, indicating that computer a and computer B can communicate with each other. Next, there are two integers C and D in the Q line, that is to query whether C and D can communicate. The integers in each line are separated by spaces, and N, m and Q are not more than 1000.
###Output format:
The output is Q rows, that is, the results of Q queries corresponding to the input. If communication is possible, output 1, otherwise output 0.
###Input example:
```in
3 2 1
1 2
2 3
1 3
```
###Output example:
```out
one
```







answer:If there is no answer, please comment