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

PROGRAMMING:Row seats

Luz5年前 (2021-05-10)题库475
The most delicate thing to arrange a banquet is to arrange seats for the guests. In any case, you can't put two enemies at the same banquet table! This difficult task is now up to you. For any pair of guests, please write a program to tell the host whether they can be arranged together.
###Input format:
Enter three positive integers in the first line: ` n '($$$Le $$100), that is, the total number of guests coming to the banquet, then these people are numbered from 1 to ` n'` M 'is the number of known relations between two guests` K 'is the number of queries. Then, in the "m" line, each line gives the relationship between a pair of guests in the format of "guest 1 guest 2 Relationship", where "relationship" is 1, indicating that they are friends, and - 1 means that they are enemies. Notice that two people can't be both friends and enemies. Finally, there are "K" lines, and each line gives a pair of guest numbers to query.
Let's assume that a friend's friend is also a friend. But the enemy of an enemy is not necessarily a friend, and the enemy of a friend is not necessarily an enemy. Only a simple and direct hostile relationship can never be at the same table.
###Output format:
Output a row of results for each query: if two guests are friends and have no hostile relationship, output 'no problem'; If they are not friends, but they are not hostile, output "OK"; If there is hostility between them, but they also have common friends, output "OK but..."; If there is only a hostile relationship between them, output 'no way'.
###Input example:
```in
7 8 4
5 6 1
2 7 -1
1 3 1
3 4 1
6 7 -1
1 2 1
1 4 1
2 3 -1
3 4
5 7
2 3
7 2
```
###Output example:
```out
No problem
OK
OK but...
No way
```






answer:If there is no answer, please comment