# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
95225 | zeyad49 | Topovi (COCI15_topovi) | C++17 | 1617 ms | 39820 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <cstdio>
#include <iostream>
#include <map>
using namespace std;
map<int,int> rows,cols,cntRows,cntCols;
map <pair<int, int>, int> power;
long long ans;
int n;
void update(int r,int c,int x) {
// subtract all cols with xor !=original xor of row r
int original;
original=rows[r];
int y=n-cntCols[original];
ans-=y;
// add all cols with xor != new xor of row r
int newXor=original^x;
rows[r]=newXor;
int z=cols[c];
cntCols[z^x]++;
cntCols[z]--;
y=n-cntCols[newXor];
ans+=y;
cntRows[original]--;
// subtract all rows with xor!=original xor of column c
original=z;
y=n-1-cntRows[original];
ans-=y;
newXor=original^x;
cols[c]=newXor;
//add all rows with xor!=new xor
y=n-1-cntRows[newXor];
ans+=y;
z=rows[r];
cntRows[z]++;
power[make_pair(r, c)] ^= x;
}
int main() {
cin>>n;
int k,p;
cin>>k>>p;
int r,c,x;
cntRows[0]=n;
cntCols[0]=n;
while(k--){
cin>>r>>c>>x;
r--;
c--;
update(r,c, x);
}
while(p-->0) {
int r1,c1,r2,c2;
cin>>r1>>c1>>r2>>c2;
r1--;
c1--;
r2--;
c2--;
int x=power[make_pair(r1, c1)];
update(r1, c1, x);
update(r2,c2,x);
cout<<ans<<'\n';
}
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |