# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
804313 |
2023-08-03T07:58:13 Z |
이동현(#10103) |
Vera and Modern Art (CCO17_art) |
C++17 |
|
159 ms |
8264 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 64 - __builtin_clzll(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 int x, y;
int v;
cin >> x >> y >> v;
// assert(y == 1);
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 |
1 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 |
30 ms |
708 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 |
159 ms |
8264 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
340 KB |
Output is correct |
2 |
Incorrect |
1 ms |
340 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |