Advertisement
Guest User

Untitled

a guest
Oct 20th, 2017
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.93 KB | None | 0 0
  1. #include <iostream>
  2. #include <algorithm>
  3. #include <unordered_set>
  4.  
  5. using namespace std;
  6. typedef long long LL;
  7.  
  8. int main() {
  9.     int N, M;
  10.     cin >> N;
  11.     cin >> M;
  12.     LL *lookup = new LL[N+1];
  13.     for (int i = 1; i <= N; i++) {
  14.         lookup[i] = 0;
  15.     }
  16.     int end = N / 2;
  17.     int k;
  18.     for (int i = 0; i < M; i++) {
  19.         for (int j = 0; j < end; j++) {
  20.             cin >> k;
  21.             lookup[k] *= 2;
  22.         }
  23.         for (int j = 0; j < end; j++) {
  24.             cin >> k;
  25.             lookup[k] = lookup[k] * 2 + 1;
  26.         }
  27.     }
  28.     bool success = true;
  29.     unordered_set<LL> all_nums;
  30.     LL K;
  31.     for (int i = 1; i <= N && success; i++) {
  32.         K = lookup[i];
  33.         if (all_nums.find(K) != all_nums.end()) {
  34.             success = false;
  35.         } else {
  36.             all_nums.insert(K);
  37.         }
  38.     }
  39.     cout << (success ? "TAK" : "NIE") << endl;
  40.     delete [] lookup;
  41.     return 0;
  42. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement