// #include <algorithm> #include <iostream> #include<cstdio> #include <set> using namespace std; string NIE = "NIE\n"; int main() { int n, m; scanf("%d %d",&n, &m); // printf("%d %d\n", n, m); set<int> negative_set; set<int> positive_set; for (int i=1; i < (m+1); i++){ negative_set.insert(i); positive_set.insert(i); } int a, b; char c; for(int i = 0; i < m; i++){ scanf("%d %d %c", &a, &b, &c); if (c == 'N'){ negative_set.erase(b); } else{ positive_set.erase(a); } } if (negative_set.size() == 0 || positive_set.size() == 0){ cout << NIE; return 0; } cout << "0\n"; cout << "1\n"; cout << "1\n"; cout << "2\n"; return 0; }
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 | // #include <algorithm> #include <iostream> #include<cstdio> #include <set> using namespace std; string NIE = "NIE\n"; int main() { int n, m; scanf("%d %d",&n, &m); // printf("%d %d\n", n, m); set<int> negative_set; set<int> positive_set; for (int i=1; i < (m+1); i++){ negative_set.insert(i); positive_set.insert(i); } int a, b; char c; for(int i = 0; i < m; i++){ scanf("%d %d %c", &a, &b, &c); if (c == 'N'){ negative_set.erase(b); } else{ positive_set.erase(a); } } if (negative_set.size() == 0 || positive_set.size() == 0){ cout << NIE; return 0; } cout << "0\n"; cout << "1\n"; cout << "1\n"; cout << "2\n"; return 0; } |