QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#656496 | #4236. Triangular Logs | chuchu | TL | 4364ms | 5036kb | C++20 | 2.9kb | 2024-10-19 13:12:40 | 2024-10-19 13:12:41 |
Judging History
answer
#pragma GCC optimize("Ofast,unroll-loops")
#include <bits/stdc++.h>
#pragma GCC target("avx,avx2,bmi,bmi2,lzcnt,popcnt,tune=native")
using namespace std;
typedef long long ll;
void solve() {
int n, q; cin >> n >> q;
int sz = (n + 7) / 8 * 8;
array<int, 3> p[sz];
for (int i = 0; i < n; ++i) {
cin >> p[i][0] >> p[i][1] >> p[i][2];
}
for (int i = n; i < sz; ++i) p[i][0] = p[i][1] = p[i][2] = -1;
sort(p, p+sz);
for (int i = 0; i < q; ++i) {
int x1, y1, x2, y2; cin >> x1 >> y1 >> x2 >> y2;
vector<unsigned> tmp[8];
int ct[8] = {0};
for (int j = 0; j < sz; j += 8) {
if (x1 > p[j+7][0]) continue;
if (x1 <= p[j][0] && p[j][0] <= x2 && y1 <= p[j][1] && p[j][1] <= y2) {
tmp[0].push_back(p[j][2]);
++ct[0];
}
if (x1 <= p[j+1][0] && p[j+1][0] <= x2 && y1 <= p[j+1][1] && p[j+1][1] <= y2) {
tmp[1].push_back(p[j+1][2]);
++ct[1];
}
if (x1 <= p[j+2][0] && p[j+2][0] <= x2 && y1 <= p[j+2][1] && p[j+2][1] <= y2) {
tmp[2].push_back(p[j+2][2]);
++ct[2];
}
if (x1 <= p[j+3][0] && p[j+3][0] <= x2 && y1 <= p[j+3][1] && p[j+3][1] <= y2) {
tmp[3].push_back(p[j+3][2]);
++ct[3];
}
if (x1 <= p[j+4][0] && p[j+4][0] <= x2 && y1 <= p[j+4][1] && p[j+4][1] <= y2) {
tmp[4].push_back(p[j+4][2]);
++ct[4];
}
if (x1 <= p[j+5][0] && p[j+5][0] <= x2 && y1 <= p[j+5][1] && p[j+5][1] <= y2) {
tmp[5].push_back(p[j+5][2]);
++ct[5];
}
if (x1 <= p[j+6][0] && p[j+6][0] <= x2 && y1 <= p[j+6][1] && p[j+6][1] <= y2) {
tmp[6].push_back(p[j+6][2]);
++ct[6];
}
if (x1 <= p[j+7][0] && p[j+7][0] <= x2 && y1 <= p[j+7][1] && p[j+7][1] <= y2) {
tmp[7].push_back(p[j+7][2]);
++ct[7];
}
if (ct[0] + ct[1] + ct[2] + ct[3] + ct[4] + ct[5] + ct[6] + ct[7] > 60 || p[j+7][0] > x2) break;
}
if (ct[0] + ct[1] + ct[2] + ct[3] + ct[4] + ct[5] + ct[6] + ct[7] > 60) { cout << "1\n"; continue; }
for (int j = 1; j < 8; ++j) for (auto z : tmp[j]) tmp[0].push_back(z);
sort(tmp[0].begin(), tmp[0].end());
bool ok = 1;
for (int j = 0; j < (int)(tmp[0].size()) - 2; ++j) {
if (tmp[0][j] + tmp[0][j+1] > tmp[0][j+2]) {
cout << "1\n";
ok = 0;
break;
}
}
if (ok) cout << "0\n";
}
}
int main() {
cin.tie(0);
cin.sync_with_stdio(0);
int t = 1;
// cin >> t;
while (t--) solve();
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3576kb
input:
9 5 1 3 3 2 3 1 3 3 4 1 2 1 2 2 5 3 2 9 1 1 2 2 1 6 3 1 5 1 1 1 2 1 1 2 2 1 1 1 3 1 2 3 2 1 1 3 3
output:
0 1 0 0 1
result:
ok 5 lines
Test #2:
score: 0
Accepted
time: 0ms
memory: 3624kb
input:
481 1 8 6788 8975 24 6552 2668 26 7948 4730 40 531 9805 110 1914 1916 164 7073 3371 165 6293 7756 170 9946 2003 179 9654 1700 215 6447 2229 221 3149 3030 242 1999 6843 242 5764 3163 249 3716 8634 250 6801 9317 260 2741 4273 282 5436 4836 284 3951 6483 288 4812 76 375 9004 5492 380 5627 5929 391 6385...
output:
1
result:
ok single line: '1'
Test #3:
score: 0
Accepted
time: 0ms
memory: 3592kb
input:
378 1 62730 50925 80731 92666 77280 61521 29236 67032 7889 35986 96802 8763 13313 49918 83582 51842 66775 47834 2286 12925 41106 39790 6698 15243 65145 56379 68496 35570 809 525 39834 16723 48002 77230 16273 16032 52615 7621 77300 92267 82517 39917 13170 89084 77751 45638 23868 49631 7758 71381 5191...
output:
1
result:
ok single line: '1'
Test #4:
score: 0
Accepted
time: 4364ms
memory: 4764kb
input:
100000 100000 299999993 206450345 26023928 334281171 300000008 18107965 318653732 299999990 82338399 299999997 393028366 37212808 299999992 208114125 82126189 300000002 303613195 34463905 270033576 299999993 49200970 300000003 249755524 5829381 300000003 367329175 12867359 300000009 337452692 131045...
output:
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ...
result:
ok 100000 lines
Test #5:
score: 0
Accepted
time: 1073ms
memory: 5036kb
input:
100000 100000 299999990 299999990 40343876 299999990 299999991 75128878 299999990 299999992 54630219 299999990 299999993 2733654 299999990 299999994 46236519 299999990 299999995 98430004 299999990 299999996 48355189 299999990 299999997 85287882 299999990 299999998 83938086 299999990 299999999 739070...
output:
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 ...
result:
ok 100000 lines
Test #6:
score: -100
Time Limit Exceeded
input:
100000 100000 586649484 999402721 770254678 406977522 613559 332964690 987164 445493717 518079399 249557488 999424331 597100212 143514230 999205612 56986976 933588533 509797 769263555 696911 930171165 201130067 833170 541105172 912457971 145501 423684829 612968794 999276416 167526939 136454621 70428...
output:
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ...