Niestety, nie byliśmy w stanie w pełni poprawnie wyświetlić tego pliku, ponieważ nie jest zakodowany w UTF-8.
Możesz pobrać ten plik i spróbować otworzyć go samodzielnie.
#define _CRT_SECURE_NO_WARNINGS
#include <algorithm>
#define ULL unsigned long long
using namespace std;
struct zaklad
{
ULL w1, w2, h1, h2;
};
zaklad ReadZaklad()
{
zaklad z;
scanf("%lld %lld %lld %lld", &(z.w1), &(z.w2), &(z.h1), &(z.h2));
return z;
}
int main()
{
int n, t;
scanf("%d", &n);
while (n--)
{
scanf("%d", &t);
bool res = true;
zaklad majoranta = ReadZaklad();
int majoranta_index = 0;
zaklad current, currentV2;
int i = 1;
for (; i < t; i++)
{
current = ReadZaklad();
if ((current.h1 > majoranta.h1 && current.w1 < majoranta.w1) ||
(current.h1 < majoranta.h1 && current.w1 > majoranta.w1) ||
(current.h2 < majoranta.h2 && current.w2 > majoranta.w2) ||
(current.h2 > majoranta.h2 && current.w2 < majoranta.w2)) //nie mog� by� dwie
{
int cpy = majoranta_index;
int j = i + 1;
for (; j < t; j++)
{
currentV2 = ReadZaklad();
if (currentV2.h1 <= majoranta.h1 && currentV2.w1 <= majoranta.w1 &&
currentV2.h1 <= current.h1 && currentV2.w1 <= current.w1 &&
currentV2.h2 >= majoranta.h2 && currentV2.w2 >= majoranta.w2 &&
currentV2.h2 >= current.h2 && currentV2.w2 >= current.w2) //nowa majoranta
{
if (currentV2.h1 != majoranta.h1 || currentV2.w1 != majoranta.w1 ||
currentV2.h1 != current.h1 || currentV2.w1 != current.w1 ||
currentV2.h2 != majoranta.h2 || currentV2.w2 != majoranta.w2 ||
currentV2.h2 != current.h2 || currentV2.w2 != current.w2) //na pewno nowa
{
majoranta_index = j;
majoranta = currentV2;
break;
}
}
}
i = j;
if (majoranta_index == cpy) //baaad
{
res = false;
break;
}
}
else if (current.h1 <= majoranta.h1 && current.w1 <= majoranta.w1 &&
current.h2 >= majoranta.h2 && current.w2 >= majoranta.w2)
if (current.h1 != majoranta.h1 || current.w1 != majoranta.w1 ||
current.h2 != majoranta.h2 || current.w2 != majoranta.w2)
{
majoranta_index = i;
majoranta = current;
}
}
printf("%s\n", (res ? "TAK" : "NIE"));
for (; i < t; i++)
scanf("%lld %lld %lld %lld", &(current.w1), &(current.w2), &(current.h1), &(current.h2));
}
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 87 88 89 90 91 92 93 94 | #define _CRT_SECURE_NO_WARNINGS #include <algorithm> #define ULL unsigned long long using namespace std; struct zaklad { ULL w1, w2, h1, h2; }; zaklad ReadZaklad() { zaklad z; scanf("%lld %lld %lld %lld", &(z.w1), &(z.w2), &(z.h1), &(z.h2)); return z; } int main() { int n, t; scanf("%d", &n); while (n--) { scanf("%d", &t); bool res = true; zaklad majoranta = ReadZaklad(); int majoranta_index = 0; zaklad current, currentV2; int i = 1; for (; i < t; i++) { current = ReadZaklad(); if ((current.h1 > majoranta.h1 && current.w1 < majoranta.w1) || (current.h1 < majoranta.h1 && current.w1 > majoranta.w1) || (current.h2 < majoranta.h2 && current.w2 > majoranta.w2) || (current.h2 > majoranta.h2 && current.w2 < majoranta.w2)) //nie mog� by� dwie { int cpy = majoranta_index; int j = i + 1; for (; j < t; j++) { currentV2 = ReadZaklad(); if (currentV2.h1 <= majoranta.h1 && currentV2.w1 <= majoranta.w1 && currentV2.h1 <= current.h1 && currentV2.w1 <= current.w1 && currentV2.h2 >= majoranta.h2 && currentV2.w2 >= majoranta.w2 && currentV2.h2 >= current.h2 && currentV2.w2 >= current.w2) //nowa majoranta { if (currentV2.h1 != majoranta.h1 || currentV2.w1 != majoranta.w1 || currentV2.h1 != current.h1 || currentV2.w1 != current.w1 || currentV2.h2 != majoranta.h2 || currentV2.w2 != majoranta.w2 || currentV2.h2 != current.h2 || currentV2.w2 != current.w2) //na pewno nowa { majoranta_index = j; majoranta = currentV2; break; } } } i = j; if (majoranta_index == cpy) //baaad { res = false; break; } } else if (current.h1 <= majoranta.h1 && current.w1 <= majoranta.w1 && current.h2 >= majoranta.h2 && current.w2 >= majoranta.w2) if (current.h1 != majoranta.h1 || current.w1 != majoranta.w1 || current.h2 != majoranta.h2 || current.w2 != majoranta.w2) { majoranta_index = i; majoranta = current; } } printf("%s\n", (res ? "TAK" : "NIE")); for (; i < t; i++) scanf("%lld %lld %lld %lld", &(current.w1), &(current.w2), &(current.h1), &(current.h2)); } return 0; } |
English