#include<fstream> #include<vector> #include<sstream> #include<iomanip> #include<iostream> #include<cstring> using namespace std; int mina, maxa, minb, maxb; int tmina, tmaxa, tminb, tmaxb; int main(int argc, char**argv) { int ncases; int numwords; int tmp = scanf("%d", &ncases); bool pos = false; int num; for(long i = 0; i < ncases; i++){ tmp = scanf("%d", &num); maxa = 0, maxb = 0; pos = false; mina = 1000000000; minb = 1000000000; for(long j = 0; j < num; j++){ tmp = scanf("%d %d %d %d", &tmina, &tmaxa, &tminb, &tmaxb); if(tmina <= mina && tminb <= minb && tmaxa >= maxa && tmaxb >= maxb){ mina = tmina; minb = tminb; maxa = tmaxa; maxb = tmaxb; pos = true; } else if(tmina < mina){ pos = false; mina = tmina; } else if(tmaxa > maxa){ pos = false; maxa = tmaxa; } else if(tminb < minb){ pos = false; minb = tminb; } else if(tmaxb > maxb){ pos = false; maxb = tmaxb; } } if(pos){ printf("TAK\n"); } else printf("NIE\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 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 | #include<fstream> #include<vector> #include<sstream> #include<iomanip> #include<iostream> #include<cstring> using namespace std; int mina, maxa, minb, maxb; int tmina, tmaxa, tminb, tmaxb; int main(int argc, char**argv) { int ncases; int numwords; int tmp = scanf("%d", &ncases); bool pos = false; int num; for(long i = 0; i < ncases; i++){ tmp = scanf("%d", &num); maxa = 0, maxb = 0; pos = false; mina = 1000000000; minb = 1000000000; for(long j = 0; j < num; j++){ tmp = scanf("%d %d %d %d", &tmina, &tmaxa, &tminb, &tmaxb); if(tmina <= mina && tminb <= minb && tmaxa >= maxa && tmaxb >= maxb){ mina = tmina; minb = tminb; maxa = tmaxa; maxb = tmaxb; pos = true; } else if(tmina < mina){ pos = false; mina = tmina; } else if(tmaxa > maxa){ pos = false; maxa = tmaxa; } else if(tminb < minb){ pos = false; minb = tminb; } else if(tmaxb > maxb){ pos = false; maxb = tmaxb; } } if(pos){ printf("TAK\n"); } else printf("NIE\n"); } return 0; } |