# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
804331 |
2023-08-03T08:04:00 Z |
이동현(#10103) |
Vera and Modern Art (CCO17_art) |
C++17 |
|
4000 ms |
8188 KB |
#include <bits/stdc++.h>
// #pragma GCC optimize("O3")
// #pragma GCC optimize("Ofast")
// #pragma GCC optimize("unroll-loops")
using namespace std;
unordered_map<signed long long, int> srt[32][32];
unordered_map<signed long long, int> saveans;
signed main(){
ios_base::sync_with_stdio(false);
cin.tie(0);
auto len = [&](signed int x){
return 32 - __builtin_clz(x);
};
int n, q;
cin >> n >> q;
signed long long A = 998244353;
signed long long B = (int)1e9 + 9;
for(int i = 0; i < n; ++i){
signed long long inx, iny;
int v;
cin >> inx >> iny >> v;
signed int x = inx, y = iny;
if(inx <= (int)1e9 && iny <= (int)1e9)
srt[len(x) - 1][len(y) - 1][A * x + B * y] += v;
}
for(int rep = 0; rep < q; ++rep){
signed int x, y;
cin >> x >> y;
auto q = saveans.find(A * x + B * y);
if(q != saveans.end()){
cout << q->second << '\n';
continue;
}
int ans = 0;
for(int i = 0; (1ll << i) <= x; ++i){
for(int j = 0; (1ll << j) <= y; ++j){
if(!(int)srt[i][j].size()) continue;
signed int px = x % (1ll << i) + (1ll << i);
signed int py = y % (1ll << j) + (1ll << j);
auto p = srt[i][j].find(A * px + B * py);
if(p != srt[i][j].end()){
ans += p->second;
}
}
}
cout << ans << '\n';
saveans[A * x + B * y] = ans;
}
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
340 KB |
Output is correct |
2 |
Incorrect |
1 ms |
340 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
54 ms |
752 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
340 KB |
Output is correct |
2 |
Correct |
149 ms |
8188 KB |
Output is correct |
3 |
Correct |
151 ms |
8156 KB |
Output is correct |
4 |
Execution timed out |
4059 ms |
8096 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 |
Incorrect |
1 ms |
340 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |