#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;
}
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
3 ms |
376 KB |
Output is correct |
3 |
Correct |
3 ms |
376 KB |
Output is correct |
4 |
Correct |
3 ms |
376 KB |
Output is correct |
5 |
Correct |
3 ms |
376 KB |
Output is correct |
6 |
Runtime error |
3 ms |
504 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
7 |
Runtime error |
2 ms |
508 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
8 |
Runtime error |
3 ms |
504 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
9 |
Runtime error |
3 ms |
504 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
10 |
Runtime error |
2 ms |
504 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
11 |
Runtime error |
6 ms |
504 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
12 |
Runtime error |
3 ms |
376 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
13 |
Runtime error |
3 ms |
508 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
14 |
Runtime error |
0 ms |
380 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
15 |
Runtime error |
4 ms |
504 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
16 |
Runtime error |
2 ms |
376 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
17 |
Runtime error |
3 ms |
376 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
18 |
Runtime error |
3 ms |
376 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
19 |
Runtime error |
2 ms |
380 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
20 |
Runtime error |
3 ms |
504 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |