답안 #804200

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
804200 2023-08-03T07:31:49 Z 이동현(#10103) Vera and Modern Art (CCO17_art) C++17
0 / 25
4000 ms 269896 KB
#include <bits/stdc++.h>
#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
using namespace std;

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

long long rv;
char c;

long long readint(){
    rv = 0;
    c = getchar();
    while(c >= '0' && c <= '9'){
        rv = rv * 10 + c - '0';
        c = getchar();
    }
    return rv;
}

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

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

    for(int rep = 0; rep < q; ++rep){
        long long x, y;
        x = readint();
        y = readint();
        int ans = 0;
        for(int i = 0; (1ll << i) <= x; ++i){
            for(int j = 0; j <= 0; ++j){
                if(!(int)srt[i][j].size()) continue;
                long long px = x % (1ll << i) + (1ll << i);
                long long py = 1;

                ans += srt[i][j][A * px + B * py];
            }
        }

        printf("%d\n", ans);
    }
    
    return 0;
}

Compilation message

Main.cpp: In function 'int main()':
Main.cpp:42:22: warning: variable 'y' set but not used [-Wunused-but-set-variable]
   42 |         long long x, y;
      |                      ^
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 468 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 275 ms 14012 KB Output is correct
2 Correct 255 ms 13976 KB Output is correct
3 Execution timed out 4067 ms 269896 KB Time limit exceeded
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 468 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 468 KB Output isn't correct
2 Halted 0 ms 0 KB -