#include<stdio.h> int main() { int t, i, j, n; long long temp1, temp2, w; scanf("%d",&t); while(t--) { scanf("%d%lld", &n, &w); long long posx[n], height[n]; for(i = 0; i < n; ++i) { scanf("%lld%lld%*lld%lld", &posx[i], &temp1, &temp2); height[i] = temp2 - temp1; } long long mposx[n]; for(i = 0; i < n; ++i) { scanf("%lld%*lld%*lld%*lld", &mposx[i]); } for(i = 0; i < n; ++i) for(j = i + 1; j < n; ++j) if(posx[i] > posx[j] && mposx[i] < mposx[j] || posx[i] < posx[j] && mposx[i] > mposx[j]) if(height[i] + height[j] > w) goto fail; puts("TAK"); continue; fail: puts("NIE"); } 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 | #include<stdio.h> int main() { int t, i, j, n; long long temp1, temp2, w; scanf("%d",&t); while(t--) { scanf("%d%lld", &n, &w); long long posx[n], height[n]; for(i = 0; i < n; ++i) { scanf("%lld%lld%*lld%lld", &posx[i], &temp1, &temp2); height[i] = temp2 - temp1; } long long mposx[n]; for(i = 0; i < n; ++i) { scanf("%lld%*lld%*lld%*lld", &mposx[i]); } for(i = 0; i < n; ++i) for(j = i + 1; j < n; ++j) if(posx[i] > posx[j] && mposx[i] < mposx[j] || posx[i] < posx[j] && mposx[i] > mposx[j]) if(height[i] + height[j] > w) goto fail; puts("TAK"); continue; fail: puts("NIE"); } return 0; } |