Submission #156148

#TimeUsernameProblemLanguageResultExecution timeMemory
156148mdn2002Topovi (COCI15_topovi)C++14
30 / 120
6 ms508 KiB
#include<bits/stdc++.h> using namespace std; long long mod=1e9+7; int n,k,p,xr[105][105],pw[105][105],ans; int main() { cin>>n>>k>>p; for(int i=0;i<k;i++) { int x,y,z; cin>>x>>y>>z; x--,y--; pw[x][y]=z; for(int j=0;j<n;j++) { if(j==x)continue; xr[j][y]^=z; } for(int j=0;j<n;j++) { if(j==y)continue; xr[x][j]^=z; } } for(int i=0;i<n;i++) { for(int j=0;j<n;j++) { if(xr[i][j]!=0)ans++; } } while(p--) { int x,y,x1,y1; cin>>x>>y>>x1>>y1; x--,y--,x1--,y1--; int z=pw[x][y]; pw[x1][y1]=z; pw[x][y]=0; for(int j=0;j<n;j++) { if(j==x)continue; bool t=false,f=false; if(xr[j][y]!=0)t=true; if(xr[j][y]==0)f=true; xr[j][y]^=z; if(xr[j][y]==0&&t==true)ans--; if(xr[j][y]!=0&&f==true)ans++; } for(int j=0;j<n;j++) { if(j==y)continue; bool t=false,f=false; if(xr[x][j]!=0)t=true; if(xr[x][j]==0)f=true; xr[x][j]^=z; if(xr[x][j]==0&&t==true)ans--; if(xr[x][j]!=0&&f==true)ans++; } for(int j=0;j<n;j++) { if(j==x1)continue; bool t=false,f=false; if(xr[j][y1]==0)t=true; if(xr[j][y1]!=0)f=true; xr[j][y1]^=z; if(xr[j][y1]!=0&&t==true)ans++; if(xr[j][y1]==0&&f==true)ans--; } for(int j=0;j<n;j++) { if(j==y1)continue; bool t=false,f=false; if(xr[x1][j]==0)t=true; if(xr[x1][j]!=0)f=true; xr[x1][j]^=z; if(xr[x1][j]!=0&&t==true)ans++; if(xr[x1][j]==0&&f==true)ans--; } cout<<ans<<endl; } }
#Verdict Execution timeMemoryGrader output
Fetching results...