-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path00665 False coin.cpp
61 lines (59 loc) · 1.55 KB
/
00665 False coin.cpp
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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
#include <bits/stdc++.h>
#define ll long long
#define endl '\n'
#define pb push_back
using namespace std;
int main(){
ios_base::sync_with_stdio(false);
cin.tie();
ll t, help = 0;
cin >> t;
while(t--) {
if(help) cout << endl;
help = 1;
ll n, k;
cin >> n >> k;
vector <ll> coins(n+1);
while(k--){
ll pi, aux;
cin >> pi;
vector <ll> s1, s2;
for(ll i = 0; i < pi; i++) {
cin >> aux;
s1.pb(aux);
}
for(ll i = 0; i < pi; i++) {
cin >> aux;
s2.pb(aux);
}
string s;
cin >> s;
if(s == "=") {
for(ll val : s1) coins[val] = 1;
for(ll val : s2) coins[val] = 1;
}
else {
for(ll val : s1) if(coins[val]!=1)coins[val] = -1;
for(ll val : s2) if(coins[val]!=1)coins[val] = -1;
for(ll i = 1; i <= n; i++) {
if(coins[i] != -1) {
coins[i] = 1;
}
else{
coins[i] = 0;
}
}
}
}
ll cont = 0, pos = 0;
for(ll i = 1; i <= n; i++) {
if(coins[i] == 0){
pos = i;
cont++;
}
if(cont == 2) break;
}
if(cont > 1) cout << 0 << endl;
else cout << pos << endl;
}
}