Submission #803470

# Submission time Handle Problem Language Result Execution time Memory
803470 2023-08-03T04:34:05 Z DK 아즈버지비우(#10138) Vera and Modern Art (CCO17_art) C++17
0 / 25
4000 ms 30804 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;
        if(x>1e9 || y>1e9)  continue;
        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 45 ms 560 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 4066 ms 12596 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 2001 ms 30760 KB Output is correct
3 Correct 1820 ms 30804 KB Output is correct
4 Execution timed out 4062 ms 25744 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 45 ms 560 KB Output isn't correct
3 Halted 0 ms 0 KB -