-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path406B.cpp
More file actions
42 lines (41 loc) · 879 Bytes
/
406B.cpp
File metadata and controls
42 lines (41 loc) · 879 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
#include <bits/stdc++.h>
using namespace std;
int main()
{
int n, m;
scanf("%d %d", &n, &m);
bool cancel = false;
int count1[10000+1],count2[10000+1];
memset(count1,-1,sizeof(count1));
memset(count2,-1,sizeof(count2));
bool vis[m];
memset(vis,false,sizeof(vis));
for (int i = 0; i < m; i++)
{
int p;
scanf("%d", &p);
for(int j = 0; j < p; j++)
{
int b;
scanf("%d", &b);
if(b < 0){
count1[abs(b)] = i;
}
else count2[b] = i;
if(count1[abs(b)]==count2[abs(b)]){
vis[i] = true;
}
}
}
for (int i = 0; i < m; i++)
{
if(!vis[i]){
cancel = true;
break;
}
}
if(cancel){
printf("YES\n");
}
else printf("NO\n");
}