Submission #803604

# Submission time Handle Problem Language Result Execution time Memory
803604 2023-08-03T05:05:48 Z 반딧불(#10100) Vera and Modern Art (CCO17_art) C++17
0 / 25
4000 ms 648444 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<int, int>, 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((1LL<<i) <= qy) vy.push_back(qy % (1LL<<i) + (1LL<<i));
        }
        for(ll a: vx) for(ll b: vy) ans += mp[make_pair(a, b)];
        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);
      |         ~~~~~^~~~~~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Incorrect 594 ms 76440 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 4082 ms 582936 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 340 KB Output is correct
2 Execution timed out 4102 ms 648444 KB Time limit exceeded
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Incorrect 594 ms 76440 KB Output isn't correct
3 Halted 0 ms 0 KB -