比赛 |
国庆欢乐赛3 |
评测结果 |
RRRRRRRRRRRRRRR |
题目名称 |
Following Directions |
最终得分 |
0 |
用户昵称 |
ZZ |
运行时间 |
3.732 s |
代码语言 |
C++ |
内存使用 |
167.68 MiB |
提交时间 |
2025-10-05 11:01:49 |
显示代码纯文本
#include<bits/stdc++.h>
using namespace std;
short n,m[1501][1501],c[1500][1500],q,a,b;
short x,y;
int ans;
queue<short> vx[1501][1501],vy[1501][1501];
char ch;
short f(short w,short z){
vx[w][z].push(x);
vy[w][z].push(y);
if( w==n || z==n ) return m[w][z];
else if(m[w][z]) return f(w,z+1);
else return f(w+1,z);
}
int main(){
ios::sync_with_stdio(false);
cin.tie(0),cout.tie(0);
freopen("zunxun.in","r",stdin);
freopen("zunxun.out","w",stdout);
cin>>n;
for(int i=0;i<n;i++){
for(int j=0;j<n;j++){
cin>>ch;
if(ch=='R') m[i][j]=1;
}
cin>>m[i][n];
}
for(int i=0;i<n;i++){
cin>>m[n][i];
}
while(x<n){
while(y<n){
c[x][y]=f(x,y);
ans+=c[x][y];
y++;
}
x++;
y=0;
}
cout<<ans<<endl;
cin>>q;
while(q--){
cin>>a>>b;
a--;
b--;
m[a][b]=!m[a][b];
for(int i=vx[a][b].size();i>0;i--){
x=vx[a][b].front();
y=vy[a][b].front();
vx[a][b].pop();
vy[a][b].pop();
ans-=c[x][y];
c[x][y]=f(x,y);
ans+=c[x][y];
}
cout<<ans<<endl;
}
return 0;
}