Submission #804275

# Submission time Handle Problem Language Result Execution time Memory
804275 2023-08-03T07:45:00 Z 이동현(#10103) Vera and Modern Art (CCO17_art) C++17
10 / 25
4000 ms 19332 KB
#include <bits/stdc++.h>
// #pragma GCC optimize("O3")
// #pragma GCC optimize("Ofast")
// #pragma GCC optimize("unroll-loops")
using namespace std;

unordered_map<signed long long, int> srt[70][70];
unordered_map<signed long long, int> saveans;

signed main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);

    auto len = [&](signed long long x){
        return 64 - __builtin_clzll(x);
    };

    int n, q;
    cin >> n >> q;
    signed long long A = 998244353;
    signed long long B = (int)1e9 + 7;
    for(int i = 0; i < n; ++i){
        signed long long x, y;
        int v;
        cin >> x >> y >> v;
        // assert(y == 1);
        srt[len(x) - 1][len(y) - 1][A * x + B * y] += v;
    }


    for(int rep = 0; rep < q; ++rep){
        signed long long x, y;
        cin >> x >> y;

        auto q = saveans.find(A * x + B * y);
        if(q != saveans.end()){
            cout << q->second << '\n';
            continue;
        }
        
        int ans = 0;
        for(int i = 0; (1ll << i) <= x; ++i){
            for(int j = 0; (1ll << j) <= y; ++j){
                if(!(int)srt[i][j].size()) continue;
                signed long long px = x % (1ll << i) + (1ll << i);
                signed long long py = y % (1ll << j) + (1ll << j);

                auto p = srt[i][j].find(A * px + B * py);
                if(p != srt[i][j].end()){
                    ans += p->second;
                }
            }
        }

        cout << ans << '\n';

        saveans[A * x + B * y] = ans;
    }
    
    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 596 KB Output is correct
2 Correct 7 ms 720 KB Output is correct
3 Correct 7 ms 712 KB Output is correct
4 Correct 108 ms 872 KB Output is correct
5 Correct 111 ms 832 KB Output is correct
6 Correct 29 ms 924 KB Output is correct
7 Correct 27 ms 852 KB Output is correct
8 Correct 28 ms 896 KB Output is correct
9 Correct 29 ms 852 KB Output is correct
10 Correct 25 ms 856 KB Output is correct
11 Correct 27 ms 896 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 942 ms 19140 KB Output is correct
2 Correct 984 ms 19332 KB Output is correct
3 Correct 1981 ms 18512 KB Output is correct
4 Correct 1918 ms 18620 KB Output is correct
5 Correct 800 ms 18580 KB Output is correct
6 Correct 769 ms 18548 KB Output is correct
7 Correct 791 ms 18628 KB Output is correct
8 Correct 787 ms 18552 KB Output is correct
9 Correct 805 ms 18576 KB Output is correct
10 Correct 971 ms 18564 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 468 KB Output is correct
2 Correct 157 ms 8392 KB Output is correct
3 Correct 182 ms 8336 KB Output is correct
4 Execution timed out 4070 ms 8212 KB Time limit exceeded
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 596 KB Output is correct
2 Correct 7 ms 720 KB Output is correct
3 Correct 7 ms 712 KB Output is correct
4 Correct 108 ms 872 KB Output is correct
5 Correct 111 ms 832 KB Output is correct
6 Correct 29 ms 924 KB Output is correct
7 Correct 27 ms 852 KB Output is correct
8 Correct 28 ms 896 KB Output is correct
9 Correct 29 ms 852 KB Output is correct
10 Correct 25 ms 856 KB Output is correct
11 Correct 27 ms 896 KB Output is correct
12 Correct 942 ms 19140 KB Output is correct
13 Correct 984 ms 19332 KB Output is correct
14 Correct 1981 ms 18512 KB Output is correct
15 Correct 1918 ms 18620 KB Output is correct
16 Correct 800 ms 18580 KB Output is correct
17 Correct 769 ms 18548 KB Output is correct
18 Correct 791 ms 18628 KB Output is correct
19 Correct 787 ms 18552 KB Output is correct
20 Correct 805 ms 18576 KB Output is correct
21 Correct 971 ms 18564 KB Output is correct
22 Correct 1 ms 468 KB Output is correct
23 Correct 157 ms 8392 KB Output is correct
24 Correct 182 ms 8336 KB Output is correct
25 Execution timed out 4070 ms 8212 KB Time limit exceeded
26 Halted 0 ms 0 KB -