# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
803699 |
2023-08-03T05:31:40 Z |
이동현(#10103) |
Vera and Modern Art (CCO17_art) |
C++17 |
|
4000 ms |
10508 KB |
#include <bits/stdc++.h>
#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#define int long long
using namespace std;
vector<array<int, 3>> srt[70][70];
signed main(){
ios_base::sync_with_stdio(false);
cin.tie(0);
auto len = [&](int x){
return 64 - __builtin_clzll(x);
};
int n, q;
cin >> n >> q;
for(int i = 0; i < n; ++i){
int x, y, v;
cin >> x >> y >> v;
srt[len(x) - 1][len(y) - 1].push_back({x, y, v});
}
for(int i = 0; i < 70; ++i){
for(int j = 0; j < 70; ++j){
sort(srt[i][j].begin(), srt[i][j].end());
for(int k = 1; k < (int)srt[i][j].size(); ++k){
srt[i][j][k][2] += srt[i][j][k - 1][2];
}
}
}
for(int rep = 0; rep < q; ++rep){
int x, y;
cin >> x >> y;
int ans = 0;
for(int i = 0; (1 << i) <= x; ++i){
for(int j = 0; (1 << j) <= y; ++j){
int px = x % (1 << i) + (1 << i);
int py = y % (1 << j) + (1 << j);
int p1 = lower_bound(srt[i][j].begin(), srt[i][j].end(), array<int, 3>{px, py, -1}) - srt[i][j].begin();
int p2 = lower_bound(srt[i][j].begin(), srt[i][j].end(), array<int, 3>{px, py + 1, -1}) - srt[i][j].begin() - 1;
if(p1 <= p2){
ans += srt[i][j][p2][2];
if(p1) ans -= srt[i][j][p1 - 1][2];
}
}
}
cout << ans << '\n';
}
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
340 KB |
Output is correct |
2 |
Runtime error |
2 ms |
852 KB |
Execution killed with signal 11 |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
72 ms |
10508 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
340 KB |
Output is correct |
2 |
Correct |
725 ms |
3684 KB |
Output is correct |
3 |
Correct |
720 ms |
3752 KB |
Output is correct |
4 |
Execution timed out |
4081 ms |
3952 KB |
Time limit exceeded |
5 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
340 KB |
Output is correct |
2 |
Runtime error |
2 ms |
852 KB |
Execution killed with signal 11 |
3 |
Halted |
0 ms |
0 KB |
- |