# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
164106 | beso123 | Topovi (COCI15_topovi) | C++14 | 1630 ms | 35252 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
#define ll long long
using namespace std;
map<int,int> xorr,xorc,cntr,cntc;
map<pair<int,int>,int> rook;
ll ans=0;
int n,k,p;
void add(int r,int c,int x){
rook[{r,c}]^=x;
ans-=n-cntc[xorr[r]];
ans-=n-cntr[xorc[c]];
if(xorr[r]!=xorc[c])
ans++;
cntc[xorc[c]]--;
cntr[xorr[r]]--;
xorr[r]^=x;
xorc[c]^=x;
cntc[xorc[c]]++;
cntr[xorr[r]]++;
ans+=n-cntc[xorr[r]];
ans+=n-cntr[xorc[c]];
if(xorr[r]!=xorc[c])
ans--;
}
int main(){
ios::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
cin>>n>>k>>p;
cntr[0]=n;
cntc[0]=n;
rep(i,k){
int r,c,x;
cin >> r >> c >> x;
add(r,c,x);
}
while(p--){
int r1,c1,r2,c2;
cin>>r1>>c1>>r2>>c2;
int x=rook[{r1,c1}];
add(r1,c1,x);
add(r2,c2,x);
cout<<ans<<'\n';
}
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |