#include <algorithm>
#include <limits>
#include <iostream>
#include <iterator>
#include <vector>
struct mirror {
int w1, w2, h1, h2;
int cnt;
mirror(int w1 = 0, int w2 = 0, int h1 = 0, int h2 = 0) : w1(w1), w2(w2), h1(h1), h2(h2), cnt(0) { }
bool operator==(const mirror &that) {
return w1 == that.w1 && w2 == that.w2 && h1 == that.h1 && h2 == that.h2;
}
};
std::istream& operator>>(std::istream &stream, mirror &mirror) {
stream >> mirror.w1 >> mirror.w2 >> mirror.h1 >> mirror.h2;
}
void testcase() {
int n, minh, maxh, minw, maxw;
std::vector<mirror> mirrors;
std::cin >> n;
std::copy_n(std::istream_iterator<mirror>(std::cin), n, std::back_inserter(mirrors));
minh = minw = std::numeric_limits<int>::max();
maxh = maxw = std::numeric_limits<int>::min();
for(const mirror& m : mirrors) {
minw = std::min(minw, m.w1);
maxw = std::max(maxw, m.w2);
minh = std::min(minh, m.h1);
maxh = std::max(maxh, m.h2);
}
if(std::find(std::begin(mirrors), std::end(mirrors), mirror(minw, maxw, minh, maxh)) != std::end(mirrors))
std::cout << "TAK\n";
else
std::cout << "NIE\n";
}
int main() {
std::ios_base::sync_with_stdio(false);
int t;
std::cin >> t;
for(int i = 0; i < t; ++i)
testcase();
}
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 | #include <algorithm> #include <limits> #include <iostream> #include <iterator> #include <vector> struct mirror { int w1, w2, h1, h2; int cnt; mirror(int w1 = 0, int w2 = 0, int h1 = 0, int h2 = 0) : w1(w1), w2(w2), h1(h1), h2(h2), cnt(0) { } bool operator==(const mirror &that) { return w1 == that.w1 && w2 == that.w2 && h1 == that.h1 && h2 == that.h2; } }; std::istream& operator>>(std::istream &stream, mirror &mirror) { stream >> mirror.w1 >> mirror.w2 >> mirror.h1 >> mirror.h2; } void testcase() { int n, minh, maxh, minw, maxw; std::vector<mirror> mirrors; std::cin >> n; std::copy_n(std::istream_iterator<mirror>(std::cin), n, std::back_inserter(mirrors)); minh = minw = std::numeric_limits<int>::max(); maxh = maxw = std::numeric_limits<int>::min(); for(const mirror& m : mirrors) { minw = std::min(minw, m.w1); maxw = std::max(maxw, m.w2); minh = std::min(minh, m.h1); maxh = std::max(maxh, m.h2); } if(std::find(std::begin(mirrors), std::end(mirrors), mirror(minw, maxw, minh, maxh)) != std::end(mirrors)) std::cout << "TAK\n"; else std::cout << "NIE\n"; } int main() { std::ios_base::sync_with_stdio(false); int t; std::cin >> t; for(int i = 0; i < t; ++i) testcase(); } |
English