You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Chef and his son Chefu want to watch a match of their favourite football team playing against another team, which will take place today.
9
+
10
+
Unfortunately, Chef is busy in the kitchen preparing lunch, so he cannot watch the match. Therefore, every now and then, Chef asks Chefu about the current scores of the teams and Chefu tells him the score. However, Chefu sometimes does not specify the teams along with the score — for example, he could say "the score is 3 to 6", and there is no way to know just from this statement if it was their favourite team or the other team that scored 6 goals; in different statements, the order of teams may also be different. Other times, Chefu specifies which team scored how many goals.
11
+
12
+
Chef asks for the score and receives a reply N times. There are two types of replies:
13
+
14
+
1 A B: their favourite team scored A goals and the other team scored B goals
15
+
2 A B: one team scored A goals and the other scored B goals
16
+
Chef is asking you to help him determine the score of his favourite team after each of Chefu's replies. After each reply, based on the current reply and all previous information (but without any following replies), tell him whether it is possible to certainly determine the number of goals scored by his favourite team.
17
+
18
+
Input
19
+
The first line of the input contains a single integer T denoting the number of test cases. The description of T test cases follows.
20
+
The first line of each test case contains a single integer N.
21
+
The following N lines describe Chefu's replies in the format described above.
22
+
Output
23
+
For each of Chefu's replies, print a single line containing the string "YES" if it is possible to determine the score of Chef's favourite team after this reply or "NO" if it is impossible.
24
+
25
+
Constraints
26
+
1=T=100
27
+
1=N=104
28
+
0=A,B=109
29
+
the sum of N over all test cases does not exceed 105
30
+
there is at least one valid sequence of scored goals consistent with all replies
31
+
Subtasks
32
+
Subtask #1 (100 points): original constraints
33
+
34
+
Example Input
35
+
1
36
+
6
37
+
2 0 1
38
+
1 3 1
39
+
2 2 4
40
+
2 5 6
41
+
2 8 8
42
+
2 9 10
43
+
Example Output
44
+
NO
45
+
YES
46
+
YES
47
+
NO
48
+
YES
49
+
NO
50
+
Explanation
51
+
Example case 1:
52
+
53
+
Reply 1: Chef cannot know who scored the first goal.
54
+
Reply 2: Chefu told Chef that their favourite team has scored 3 goals so far.
55
+
Reply 3: Chef can conclude that his favourite team has scored 4 goals, since it already scored 3 goals earlier.
56
+
Reply 4: the favourite team could have scored 5 or 6 goals, but there is no way to know which option is correct.
57
+
Reply 5: since there is a tie, Chef knows that his favourite team has scored 8 goals.
58
+
Reply 6: again, Chef cannot know if his favourite team has scored 9 or 10 goals.
0 commit comments