比赛 2024暑期C班集训2 评测结果 TTTTTTTTTT
题目名称 Vera 与现代艺术 最终得分 0
用户昵称 darkMoon 运行时间 20.000 s
代码语言 C++ 内存使用 13.94 MiB
提交时间 2024-07-02 11:08:47
显示代码纯文本
#include<bits/stdc++.h>
#define int long long
#define fi first
#define se second
#define mp make_pair
using namespace std;
ifstream fin("modern.in");
ofstream fout("modern.out");
auto mread = [](){int x;fin >> x;return x;};
const int N = 2e5 + 5;
int n = mread(), m = mread(), x[N], y[N], v[N], r[N], c[N];
unordered_map<string, int> ap;
string T = "0123456789";
string Make(int x, int y){
    string ans = "";
    while(x){
        ans.push_back(T[x % 10]);
        x /= 10;
    }
    while(y){
        ans.push_back(T[y % 10]);
        y /= 10;
    }
    return ans;
}
signed main(){
    for(int i = 1; i <= n; i ++){
        x[i] = mread(), y[i] = mread(), v[i] = mread();
        auto tmp = Make(x[i], y[i]);
        if(ap.find(tmp) == ap.end())
        ap[tmp] = 0;
        ap[tmp] += v[i];
    }
    for(int i = 1; i <= m; i ++){
        r[i] = mread(), c[i] = mread();
        int ans = 0;
        for(int j = 0; j <= 60; j ++){
            int t1 = 1ll << j;
            if(t1 > r[i])
            break;
            for(int k = 0; k <= 60; k ++){
                int t2 = 1ll << k;
                if(t2 > c[i])
                break;
                auto tmp = Make(r[i] % t1 + t1, c[i] % t2 + t2);
                if(ap.find(tmp) != ap.end())
                ans += ap[tmp];
            }
        }
        fout << ans << "\n";
    }
    return 0;
}