#include <iostream> #include <sstream> int main() { int t; std::cin >> t; for ( int x = 0; x < t; ++x ) { long n; long long w1, w2, h1, h2; std::cin >> n; int z=0; long long **table = new long long*[n];//Nie małe tworzenie tablicy for( int i = 0; i < n; i++ ) { table[i] = new long long[4]; } std::cin.ignore(); for( int y = 0; y < n; y++ ) { std::string temp; std::getline(std::cin, temp); std::istringstream line(temp); for( int v=0; v < 4; v++ ) { line >> table[y][v]; } }//Dotąd chyba działa long long w1min = table[0][0], w2max = table[0][1], h1min = table[0][2], h2max = table[0][3]; for( int y = 0; y < n; y++ ) { if( table[y][0] < w1min ) { w1min = table[y][0]; } if( table[y][1] > w2max ) { w2max = table[y][1]; } if( table[y][2] < h1min ) { h1min = table[y][2]; } if( table[y][3] > h2max ) { h2max = table[y][3]; } } z = 0; for( int y = 0; y < n; ++y ) { if( ( table[y][0] == w1min && table[y][1] == w2max ) && ( table[y][2] == h1min && table[y][3] == h2max ) ) { z = 1; } } if( z == 1 ) { std::cout << "TAK\n"; } else { std::cout << "NIE\n"; } delete[] table; } }
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 | #include <iostream> #include <sstream> int main() { int t; std::cin >> t; for ( int x = 0; x < t; ++x ) { long n; long long w1, w2, h1, h2; std::cin >> n; int z=0; long long **table = new long long*[n];//Nie małe tworzenie tablicy for( int i = 0; i < n; i++ ) { table[i] = new long long[4]; } std::cin.ignore(); for( int y = 0; y < n; y++ ) { std::string temp; std::getline(std::cin, temp); std::istringstream line(temp); for( int v=0; v < 4; v++ ) { line >> table[y][v]; } }//Dotąd chyba działa long long w1min = table[0][0], w2max = table[0][1], h1min = table[0][2], h2max = table[0][3]; for( int y = 0; y < n; y++ ) { if( table[y][0] < w1min ) { w1min = table[y][0]; } if( table[y][1] > w2max ) { w2max = table[y][1]; } if( table[y][2] < h1min ) { h1min = table[y][2]; } if( table[y][3] > h2max ) { h2max = table[y][3]; } } z = 0; for( int y = 0; y < n; ++y ) { if( ( table[y][0] == w1min && table[y][1] == w2max ) && ( table[y][2] == h1min && table[y][3] == h2max ) ) { z = 1; } } if( z == 1 ) { std::cout << "TAK\n"; } else { std::cout << "NIE\n"; } delete[] table; } } |