#include <iostream> using namespace std; int main(int argc, char *argv[]) { int t, n; cin >> t; for (int l=0; l<t; l++) { int w=0, h=0, pom=0, pom_w=0, pom_h=0; cin>>n; int tab[n][4]; for (int i=0; i<n; i++) { for (int j=0; j<4; j++) { cin>>tab[i][j]; } } w = tab[0][1] - tab[0][0]; h = tab[0][3] - tab[0][2]; for (int i=0; i<n-1; i++) { if (tab[i+1][1] - tab[i+1][0] > w){w = tab[i+1][1] - tab[i+1][0]; pom_w = i+1;} if (tab[i+1][3] - tab[i+1][2] > h){h = tab[i+1][3] - tab[i+1][2]; pom_h = i+1;} if (w == tab[i+1][1] - tab[i+1][0] && h == tab[i+1][3] - tab[i+1][2]) {pom++;} } if ((pom_w != -1) && (pom_h != -1) && (pom_w == pom_h) && pom < n-1) cout << "TAK\n"; else cout << "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 | #include <iostream> using namespace std; int main(int argc, char *argv[]) { int t, n; cin >> t; for (int l=0; l<t; l++) { int w=0, h=0, pom=0, pom_w=0, pom_h=0; cin>>n; int tab[n][4]; for (int i=0; i<n; i++) { for (int j=0; j<4; j++) { cin>>tab[i][j]; } } w = tab[0][1] - tab[0][0]; h = tab[0][3] - tab[0][2]; for (int i=0; i<n-1; i++) { if (tab[i+1][1] - tab[i+1][0] > w){w = tab[i+1][1] - tab[i+1][0]; pom_w = i+1;} if (tab[i+1][3] - tab[i+1][2] > h){h = tab[i+1][3] - tab[i+1][2]; pom_h = i+1;} if (w == tab[i+1][1] - tab[i+1][0] && h == tab[i+1][3] - tab[i+1][2]) {pom++;} } if ((pom_w != -1) && (pom_h != -1) && (pom_w == pom_h) && pom < n-1) cout << "TAK\n"; else cout << "NIE\n"; } return 0; } |