답안 #803390

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
803390 2023-08-03T04:22:26 Z DK 아즈버지비우(#10138) Vera and Modern Art (CCO17_art) C++17
0 / 25
4000 ms 836140 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<60;j++)   res+=mpx[j][pll(x%(1<<j), y)];
        for(int j=0;j<60;j++)   res+=mpy[j][pll(x, y%(1<<j))];
        for(int j=0;j<60;j++)   for(int k=0;k<60;k++)   res+=mpxy[j][k][pll(x%(1<<j), y%(1<<k))];
        cout << res << '\n';
    }
}
int main()
{
    gibon
    input();
}
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 1876 KB Output is correct
2 Incorrect 1878 ms 276544 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 4090 ms 836140 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 1876 KB Output is correct
2 Execution timed out 4102 ms 825804 KB Time limit exceeded
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 1876 KB Output is correct
2 Incorrect 1878 ms 276544 KB Output isn't correct
3 Halted 0 ms 0 KB -