过样例0pts
查看原帖
过样例0pts
360025
zzyaba楼主2024/5/1 21:08
#include<bits/stdc++.h>
#define int long long
using namespace std;
int n,k,p,x,y,w,r1,c1,r2,c2,ans;
unordered_map<int,unordered_map<int,int> >mp;
unordered_map<int,int>row,col;
unordered_map<int,pair<int,int> >cnt;
signed main(){
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    cin>>n>>k>>p;
    while(k--){
        cin>>x>>y>>w;
        mp[x][y]=w;
        row[x]^=w;
        col[y]^=w;
    }
    for(auto&it:row){
        cnt[it.second].first++;
    }
    for(auto&it:col){
        cnt[it.second].second++;
    }
    cnt[0].first+=n-row.size();
    cnt[0].second+=n-col.size();
    for(auto&it:cnt){
        ans+=it.second.first*it.second.second;
    }
    while(p--){
        cin>>r1>>c1>>r2>>c2;
        cnt[row[r1]].first--;
        ans-=cnt[row[r1]].second;
        cnt[row[r1]^=mp[r1][c1]].first++;
        ans+=cnt[row[r1]].second;
        cnt[col[c1]].first--;
        ans-=cnt[col[c1]].second;
        cnt[col[c1]^=mp[r1][c1]].first++;
        ans+=cnt[col[c1]].second;
        cnt[row[r2]].first--;
        ans-=cnt[row[r2]].second;
        cnt[row[r2]^=mp[r1][c1]].first++;
        ans+=cnt[row[r2]].second;
        cnt[col[c2]].first--;
        ans-=cnt[col[c2]].second;
        cnt[col[c2]^=mp[r1][c1]].first++;
        ans+=cnt[col[c2]].second;
        mp[r2][c2]=mp[r1][c1];
        mp[r1][c1]=0;
        cout<<n*n-ans<<endl;
    }
}

赛时样例全过了,非常开心的以为拿了100pts

2024/5/1 21:08
加载中...