#include <bits/stdc++.h>
#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
using namespace std;
unordered_map<long long, int> srt[70][70];
signed main(){
ios_base::sync_with_stdio(false);
cin.tie(0);
auto len = [&](long long x){
return 64 - __builtin_clzll(x);
};
int n, q;
cin >> n >> q;
long long A = 998244353;
long long B = (int)1e9 + 7;
// n = q = 200000;
for(int i = 0; i < n; ++i){
long long x, y;
int v;
cin >> x >> y >> v;
// x = uid(gen), y = uid(gen), v = uid(gen);
srt[len(x) - 1][len(y) - 1][A * x + B * y] += v;
}
for(int rep = 0; rep < q; ++rep){
long long x, y;
cin >> x >> y;
int ans = 0;
for(int i = 0; (1ll << i) <= x; ++i){
for(int j = 0; j <= 0; ++j){
if(!(int)srt[i][j].size()) continue;
long long px = x % (1ll << i) + (1ll << i);
long long py = 1;
ans += srt[i][j][A * px + B * py];
}
}
cout << ans << '\n';
}
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
468 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
191 ms |
14020 KB |
Output is correct |
2 |
Correct |
198 ms |
14000 KB |
Output is correct |
3 |
Execution timed out |
4035 ms |
304084 KB |
Time limit exceeded |
4 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
468 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
468 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |