Submission #803617

# Submission time Handle Problem Language Result Execution time Memory
803617 2023-08-03T05:07:50 Z 반딧불(#10100) Vera and Modern Art (CCO17_art) C++17
5 / 25
4000 ms 1048576 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((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 340 KB Output is correct
2 Correct 1474 ms 278660 KB Output is correct
3 Correct 1476 ms 278984 KB Output is correct
4 Correct 1806 ms 442824 KB Output is correct
5 Correct 1808 ms 442808 KB Output is correct
6 Correct 465 ms 112348 KB Output is correct
7 Correct 491 ms 109976 KB Output is correct
8 Correct 463 ms 109728 KB Output is correct
9 Correct 501 ms 107864 KB Output is correct
10 Correct 474 ms 109772 KB Output is correct
11 Correct 507 ms 113184 KB Output is correct
# Verdict Execution time Memory Grader output
1 Execution timed out 4040 ms 1048576 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Execution timed out 4082 ms 680568 KB Time limit exceeded
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 340 KB Output is correct
2 Correct 1474 ms 278660 KB Output is correct
3 Correct 1476 ms 278984 KB Output is correct
4 Correct 1806 ms 442824 KB Output is correct
5 Correct 1808 ms 442808 KB Output is correct
6 Correct 465 ms 112348 KB Output is correct
7 Correct 491 ms 109976 KB Output is correct
8 Correct 463 ms 109728 KB Output is correct
9 Correct 501 ms 107864 KB Output is correct
10 Correct 474 ms 109772 KB Output is correct
11 Correct 507 ms 113184 KB Output is correct
12 Execution timed out 4040 ms 1048576 KB Time limit exceeded
13 Halted 0 ms 0 KB -