답안 #804263

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
804263 2023-08-03T07:42:24 Z 이동현(#10103) Vera and Modern Art (CCO17_art) C++17
10 / 25
4000 ms 9900 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];

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;
        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';
    }
    
    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 468 KB Output is correct
2 Correct 10 ms 596 KB Output is correct
3 Correct 10 ms 688 KB Output is correct
4 Correct 108 ms 812 KB Output is correct
5 Correct 107 ms 808 KB Output is correct
6 Correct 26 ms 724 KB Output is correct
7 Correct 28 ms 828 KB Output is correct
8 Correct 26 ms 828 KB Output is correct
9 Correct 26 ms 820 KB Output is correct
10 Correct 25 ms 804 KB Output is correct
11 Correct 26 ms 724 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1070 ms 9900 KB Output is correct
2 Correct 988 ms 9828 KB Output is correct
3 Correct 2059 ms 9280 KB Output is correct
4 Correct 2157 ms 9252 KB Output is correct
5 Correct 1113 ms 9308 KB Output is correct
6 Correct 728 ms 9244 KB Output is correct
7 Correct 781 ms 9312 KB Output is correct
8 Correct 924 ms 9344 KB Output is correct
9 Correct 785 ms 9276 KB Output is correct
10 Correct 737 ms 9244 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 468 KB Output is correct
2 Correct 183 ms 5292 KB Output is correct
3 Correct 173 ms 5300 KB Output is correct
4 Execution timed out 4061 ms 5184 KB Time limit exceeded
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 468 KB Output is correct
2 Correct 10 ms 596 KB Output is correct
3 Correct 10 ms 688 KB Output is correct
4 Correct 108 ms 812 KB Output is correct
5 Correct 107 ms 808 KB Output is correct
6 Correct 26 ms 724 KB Output is correct
7 Correct 28 ms 828 KB Output is correct
8 Correct 26 ms 828 KB Output is correct
9 Correct 26 ms 820 KB Output is correct
10 Correct 25 ms 804 KB Output is correct
11 Correct 26 ms 724 KB Output is correct
12 Correct 1070 ms 9900 KB Output is correct
13 Correct 988 ms 9828 KB Output is correct
14 Correct 2059 ms 9280 KB Output is correct
15 Correct 2157 ms 9252 KB Output is correct
16 Correct 1113 ms 9308 KB Output is correct
17 Correct 728 ms 9244 KB Output is correct
18 Correct 781 ms 9312 KB Output is correct
19 Correct 924 ms 9344 KB Output is correct
20 Correct 785 ms 9276 KB Output is correct
21 Correct 737 ms 9244 KB Output is correct
22 Correct 1 ms 468 KB Output is correct
23 Correct 183 ms 5292 KB Output is correct
24 Correct 173 ms 5300 KB Output is correct
25 Execution timed out 4061 ms 5184 KB Time limit exceeded
26 Halted 0 ms 0 KB -