# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
804323 |
2023-08-03T08:01:51 Z |
이동현(#10103) |
Vera and Modern Art (CCO17_art) |
C++17 |
|
151 ms |
8172 KB |
#include <bits/stdc++.h>
// #pragma GCC optimize("O3")
// #pragma GCC optimize("Ofast")
// #pragma GCC optimize("unroll-loops")
using namespace std;
unordered_map<signed int, int> srt[32][32];
unordered_map<signed int, 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 int A = 998244353;
signed int B = (int)1e9 + 7;
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 |
2 ms |
372 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
58 ms |
740 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
340 KB |
Output is correct |
2 |
Incorrect |
151 ms |
8172 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
340 KB |
Output is correct |
2 |
Incorrect |
2 ms |
372 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |