# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
804141 | 2023-08-03T07:19:53 Z | 박상훈(#10101) | Vera and Modern Art (CCO17_art) | C++17 | 4000 ms | 14188 KB |
#include <bits/stdc++.h> using namespace std; typedef long long ll; struct Node{ ll x, y; int sum; Node(){} Node(ll _x, ll _y, int _sum): x(_x), y(_y), sum(_sum) {} bool operator < (const Node &N) const{ return tie(x, y) < tie(N.x, N.y); } }; int n, q; int a[200200]; ll X[200200], Y[200200]; vector<Node> buf[64][64]; int lenx[200200], leny[200200]; void init(){ for (int i=1;i<=n;i++){ int z = 0; for (;(1LL<<z)<=X[i];z++); --z; lenx[i] = z; z = 0; for (;(1LL<<z)<=Y[i];z++); --z; leny[i] = z; ll nx = X[i] & ((1LL<<lenx[i])-1); ll ny = Y[i] & ((1LL<<leny[i])-1); buf[lenx[i]][leny[i]].emplace_back(nx, ny, a[i]); } for (int i=0;i<64;i++){ for (int j=0;j<64;j++){ sort(buf[i][j].begin(), buf[i][j].end()); for (int k=1;k<(int)buf[i][j].size();k++) if (buf[i][j][k].x == buf[i][j][k-1].x && buf[i][j][k].y == buf[i][j][k-1].y){ buf[i][j][k].sum += buf[i][j][k-1].sum; } } } } int main(){ scanf("%d %d", &n, &q); for (int i=1;i<=n;i++) scanf("%lld %lld %d", X+i, Y+i, a+i); init(); for (int z=1;z<=q;z++){ ll x, y; scanf("%lld %lld", &x, &y); int ans = 0; for (int i=0;(1LL<<i)<=x;i++){ ll nx = x & ((1LL<<i)-1); for (int j=0;(1LL<<j)<=y;j++){ ll ny = y & ((1LL<<j)-1); auto iter = upper_bound(buf[i][j].begin(), buf[i][j].end(), Node(nx, ny, 0)); if (iter==buf[i][j].begin()) continue; --iter; if (iter->x == nx && iter->y == ny) ans += iter->sum; } } printf("%d\n", ans); } }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 340 KB | Output is correct |
2 | Correct | 12 ms | 580 KB | Output is correct |
3 | Correct | 12 ms | 576 KB | Output is correct |
4 | Correct | 56 ms | 552 KB | Output is correct |
5 | Correct | 54 ms | 544 KB | Output is correct |
6 | Correct | 17 ms | 548 KB | Output is correct |
7 | Correct | 17 ms | 552 KB | Output is correct |
8 | Correct | 15 ms | 468 KB | Output is correct |
9 | Correct | 18 ms | 556 KB | Output is correct |
10 | Correct | 15 ms | 552 KB | Output is correct |
11 | Correct | 16 ms | 552 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1290 ms | 11684 KB | Output is correct |
2 | Correct | 1312 ms | 12440 KB | Output is correct |
3 | Correct | 2615 ms | 14108 KB | Output is correct |
4 | Correct | 2730 ms | 14188 KB | Output is correct |
5 | Correct | 1136 ms | 13988 KB | Output is correct |
6 | Correct | 1156 ms | 13852 KB | Output is correct |
7 | Correct | 1089 ms | 14116 KB | Output is correct |
8 | Correct | 1242 ms | 14040 KB | Output is correct |
9 | Correct | 1122 ms | 13780 KB | Output is correct |
10 | Correct | 1247 ms | 14116 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 340 KB | Output is correct |
2 | Correct | 256 ms | 6404 KB | Output is correct |
3 | Correct | 243 ms | 6472 KB | Output is correct |
4 | Execution timed out | 4043 ms | 6968 KB | Time limit exceeded |
5 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 340 KB | Output is correct |
2 | Correct | 12 ms | 580 KB | Output is correct |
3 | Correct | 12 ms | 576 KB | Output is correct |
4 | Correct | 56 ms | 552 KB | Output is correct |
5 | Correct | 54 ms | 544 KB | Output is correct |
6 | Correct | 17 ms | 548 KB | Output is correct |
7 | Correct | 17 ms | 552 KB | Output is correct |
8 | Correct | 15 ms | 468 KB | Output is correct |
9 | Correct | 18 ms | 556 KB | Output is correct |
10 | Correct | 15 ms | 552 KB | Output is correct |
11 | Correct | 16 ms | 552 KB | Output is correct |
12 | Correct | 1290 ms | 11684 KB | Output is correct |
13 | Correct | 1312 ms | 12440 KB | Output is correct |
14 | Correct | 2615 ms | 14108 KB | Output is correct |
15 | Correct | 2730 ms | 14188 KB | Output is correct |
16 | Correct | 1136 ms | 13988 KB | Output is correct |
17 | Correct | 1156 ms | 13852 KB | Output is correct |
18 | Correct | 1089 ms | 14116 KB | Output is correct |
19 | Correct | 1242 ms | 14040 KB | Output is correct |
20 | Correct | 1122 ms | 13780 KB | Output is correct |
21 | Correct | 1247 ms | 14116 KB | Output is correct |
22 | Correct | 0 ms | 340 KB | Output is correct |
23 | Correct | 256 ms | 6404 KB | Output is correct |
24 | Correct | 243 ms | 6472 KB | Output is correct |
25 | Execution timed out | 4043 ms | 6968 KB | Time limit exceeded |
26 | Halted | 0 ms | 0 KB | - |