답안 #803625

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
803625 2023-08-03T05:09:59 Z 반딧불(#10100) Vera and Modern Art (CCO17_art) C++17
5 / 25
3280 ms 21736 KB
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

int n, q;
ll px[200002], py[200002], pa[200002], pb[200002], pv[200002];
map<pair<ll, ll>, ll> mp;

int main(){
    scanf("%d %d", &n, &q);
    for(int i=1; i<=n; i++){
        scanf("%lld %lld %lld", &px[i], &py[i], &pv[i]);
        pa[i] = 1, pb[i] = 1;
        while(pa[i] * 2 <= px[i]) pa[i]*=2;
        while(pb[i] * 2 <= py[i]) pb[i]*=2;
        mp[make_pair(px[i], py[i])] += pv[i];
    }
    while(q--){
        ll qx, qy;
        scanf("%lld %lld", &qx, &qy);
        ll ans = 0;
        vector<ll> vx, vy;
        for(int i=0; i<60; i++){
            if((1LL<<i) <= qx) vx.push_back(qx % (1LL<<i) + (1LL<<i));
            if(i==0) if((1LL<<i) <= qy) vy.push_back(qy % (1LL<<i) + (1LL<<i));
        }
        for(ll a: vx) for(ll b: vy){
            auto it = mp.find(make_pair(a, b));
            if(it != mp.end()) ans += it->second;
        }
        printf("%lld\n", ans);
    }
}

Compilation message

Main.cpp: In function 'int main()':
Main.cpp:12:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   12 |     scanf("%d %d", &n, &q);
      |     ~~~~~^~~~~~~~~~~~~~~~~
Main.cpp:14:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   14 |         scanf("%lld %lld %lld", &px[i], &py[i], &pv[i]);
      |         ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Main.cpp:22:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   22 |         scanf("%lld %lld", &qx, &qy);
      |         ~~~~~^~~~~~~~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 732 ms 21736 KB Output is correct
2 Correct 768 ms 21528 KB Output is correct
3 Correct 3222 ms 19896 KB Output is correct
4 Correct 3280 ms 19940 KB Output is correct
5 Correct 1693 ms 19904 KB Output is correct
6 Correct 1573 ms 19940 KB Output is correct
7 Correct 1701 ms 19900 KB Output is correct
8 Correct 1521 ms 19948 KB Output is correct
9 Correct 1480 ms 19888 KB Output is correct
10 Correct 1553 ms 19936 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 340 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -