# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
803438 |
2023-08-03T04:29:05 Z |
DK 아즈버지비우(#10138) |
Vera and Modern Art (CCO17_art) |
C++17 |
|
4000 ms |
61468 KB |
#include <bits/stdc++.h>
#define all(v) v.begin(), v.end()
#define gibon ios::sync_with_stdio(false); cin.tie(0);
#define fi first
#define se second
#define pdd pair<long double, long double>
#define pii pair<int, int>
#define pll pair<ll, ll>
#define ppi pair<pii, pii>
#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
typedef long long ll;
using namespace std;
const int mxN=300020;
const int mxM=63;
const int MOD=1e9+7;
const ll INF=1e18;
int N, Q;
map <pll, ll> mp1, mpx[mxM], mpy[mxM], mpxy[mxM][mxM];
void input()
{
cin >> N >> Q;
for(int i=1;i<=N;i++)
{
ll x, y, v;
cin >> x >> y >> v;
ll px=1, py=1, ix=0, iy=0;
while(2*px<=x) px*=2, ix++;
while(2*py<=y) py*=2, iy++;
x-=px; y-=py;
mp1[pll(x, y)]+=v;
mpx[ix][pll(x, y)]-=v;
mpy[iy][pll(x, y)]-=v;
mpxy[ix][iy][pll(x, y)]+=v;
}
for(int i=0;i<Q;i++)
{
ll x, y;
cin >> x >> y;
ll res=0;
res+=mp1[pll(x, y)];
for(int j=0;j<30;j++) if(mpx[j].count(pll(x%(1ll<<j), y))) res+=mpx[j][pll(x%(1ll<<j), y)];
for(int j=0;j<30;j++) if(mpy[j].count(pll(x, y%(1ll<<j)))) res+=mpy[j][pll(x, y%(1ll<<j))];
for(int j=0;j<30;j++) for(int k=0;k<30;k++) if(mpxy[j][k].count(pll(x%(1ll<<j), y%(1ll<<k)))) res+=mpxy[j][k][pll(x%(1ll<<j), y%(1ll<<k))];
cout << res << '\n';
}
}
int main()
{
gibon
input();
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
468 KB |
Output is correct |
2 |
Incorrect |
46 ms |
1028 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
4038 ms |
61468 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
468 KB |
Output is correct |
2 |
Correct |
1877 ms |
30824 KB |
Output is correct |
3 |
Correct |
1899 ms |
30824 KB |
Output is correct |
4 |
Execution timed out |
4070 ms |
25728 KB |
Time limit exceeded |
5 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
468 KB |
Output is correct |
2 |
Incorrect |
46 ms |
1028 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |