// // main.cpp // her // // Created by Mikołaj Korulczyk on 10/12/2019. // Copyright © 2019 Mikołaj Korulczyk. All rights reserved. // #include <bits/stdc++.h> using namespace std; int t; int n; int l, a, b; int max_a, max_b; long long sum_a, sum_b; long long counter; bool trigger; //klucz - temperatura //wartość - jej ilość map<long long, long long> val_a; map<long long, long long> val_b; vector<long long> v1; vector<long long> v2; int main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); cin >> t; while(t--) { cin >> n; max_a = -1; max_b = -1; sum_a = 0; sum_b = 0; val_a.clear(); val_b.clear(); v1.clear(); v2.clear(); for(int i = 1; i <= n; i++) { cin >> l >> a >> b; max_a = max(max_a, a); max_b = max(max_b, b); sum_a += l*a; sum_b += l*b; counter += l; val_a[a] += l; val_b[b] += l; } for(auto i: val_a) { //cout << "(" << i.first << " " << i.second << ") "; //cout << i.second << " "; v1.push_back(i.second); } for(auto i: val_b) { //cout << "(" << i.first << " " << i.second << ") "; //cout << i.second << " "; v2.push_back(i.second); } trigger = false; sort(v1.begin(), v1.end()); sort(v2.begin(), v2.end()); if(sum_a != sum_b || max_b > max_a) { cout << "NIE" << endl; } else { cout << "TAK" << endl; } } 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 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 | // // main.cpp // her // // Created by Mikołaj Korulczyk on 10/12/2019. // Copyright © 2019 Mikołaj Korulczyk. All rights reserved. // #include <bits/stdc++.h> using namespace std; int t; int n; int l, a, b; int max_a, max_b; long long sum_a, sum_b; long long counter; bool trigger; //klucz - temperatura //wartość - jej ilość map<long long, long long> val_a; map<long long, long long> val_b; vector<long long> v1; vector<long long> v2; int main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); cin >> t; while(t--) { cin >> n; max_a = -1; max_b = -1; sum_a = 0; sum_b = 0; val_a.clear(); val_b.clear(); v1.clear(); v2.clear(); for(int i = 1; i <= n; i++) { cin >> l >> a >> b; max_a = max(max_a, a); max_b = max(max_b, b); sum_a += l*a; sum_b += l*b; counter += l; val_a[a] += l; val_b[b] += l; } for(auto i: val_a) { //cout << "(" << i.first << " " << i.second << ") "; //cout << i.second << " "; v1.push_back(i.second); } for(auto i: val_b) { //cout << "(" << i.first << " " << i.second << ") "; //cout << i.second << " "; v2.push_back(i.second); } trigger = false; sort(v1.begin(), v1.end()); sort(v2.begin(), v2.end()); if(sum_a != sum_b || max_b > max_a) { cout << "NIE" << endl; } else { cout << "TAK" << endl; } } return 0; } |