#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> pll;
typedef pair<int, int> pii;
#define MAX 110
#define MAXS 20
#define INF 1000000000000000001
#define bb ' '
#define ln '\n'
#define Ln '\n'
#define MOD 1000000007
signed main() {
ios::sync_with_stdio(false), cin.tie(0);
int N, Q;
cin >> N >> Q;
int i;
ll a, b, c;
map<pll, ll> mp;
for (i = 1; i <= N; i++) {
cin >> a >> b >> c;
mp[pll(a, b)] += c;
}
while (Q--) {
cin >> a >> b;
int i, j;
ll sum = 0;
for (i = 0; i <= 60; i++) for (j = 0; j <= 60; j++) {
if (a < (1ll << i)) continue;
if (b < (1ll << j)) continue;
ll mi, mj;
mi = 1ll << i;
mj = 1ll << j;
mi--;
mj--;
ll x, y;
x = a & mi;
y = b & mj;
x += mi + 1;
y += mj + 1;
sum += mp[pii(x, y)];
}
cout << sum << Ln;
}
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Incorrect |
592 ms |
76344 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
4081 ms |
568136 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Execution timed out |
4066 ms |
607828 KB |
Time limit exceeded |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Incorrect |
592 ms |
76344 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |