ManZhouJi @ 2024-11-03 08:51:22
50分代码(你们复制也没用)
#include<bits/stdc++.h>
using namespace std;
char explore[1002][1002];
bool step[1002][1002];
int t,n,m,k,x,y,d,ans=1;
int main(){
cin>>t;
for(int tt=1;tt<=t;tt++){
cin>>n>>m>>k;
cin>>x>>y>>d;
for(int i=1;i<=n;i++){
for(int j=1;j<=m;j++){
cin>>explore[i][j];
}
}
for(int i=1;i<=k;i++){
int xx=x,yy=y;
if(d==0) yy++;
if(d==1) xx++;
if(d==2) yy--;
if(d==3) xx--;
if(xx<1||xx>n||yy<1||yy>m||explore[xx][yy]=='x') d=(d+1)%4;
else{
if(step[xx][yy]==0) step[xx][yy]=1,ans++;
x=xx,y=yy;
}
}
cout<<ans<<endl;
ans=1;//考试时写的0,于是只能拿0分了
for(int i=1;i<=n;i++){
for(int j=1;j<=m;j++){
step[i][j]=0;
}
}
}
return 0;
}
by Mamba_End @ 2024-11-03 08:59:35
T1呢,A没
by ManZhouJi @ 2024-11-03 09:00:59
满分了
by ManZhouJi @ 2024-11-03 09:01:36
少写两句,少100分
by Alvin_Wang @ 2024-11-03 09:03:14
@ManZhouJi
漏了一个
step[x][y] = 1
因为最开始站的这个点也要设置一下
(在CSP-J现场又给过一个样例就是坑这个没设初始的)
所以 AC 代码就如下:
#include<bits/stdc++.h>
using namespace std;
char explore[1002][1002];
bool step[1002][1002];
int t,n,m,k,x,y,d,ans=1;
int main(){
cin>>t;
for(int tt=1;tt<=t;tt++){
cin>>n>>m>>k;
cin>>x>>y>>d;
step[x][y] = 1; // 加上这一行就好啦
for(int i=1;i<=n;i++){
for(int j=1;j<=m;j++){
cin>>explore[i][j];
}
}
for(int i=1;i<=k;i++){
int xx=x,yy=y;
if(d==0) yy++;
if(d==1) xx++;
if(d==2) yy--;
if(d==3) xx--;
if(xx<1||xx>n||yy<1||yy>m||explore[xx][yy]=='x') d=(d+1)%4;
else{
if(step[xx][yy]==0) step[xx][yy]=1,ans++;
x=xx,y=yy;
}
}
cout<<ans<<endl;
ans=1;
for(int i=1;i<=n;i++){
for(int j=1;j<=m;j++){
step[i][j]=0;
}
}
}
return 0;
}
by wuyouawa @ 2024-11-03 09:03:20
@ManZhouJi So what do you want to express
by ManZhouJi @ 2024-11-03 09:06:17
@Mamba_End A了(气死我嘞×2)
by Mamba_End @ 2024-11-03 09:08:12
@ManZhouJi 6,有桂
by Mamba_End @ 2024-11-03 09:13:52
@ManZhouJi 好像是
by ManZhouJi @ 2024-11-03 09:13:59
@Alvin_Wang 延迟真大,我发完step那句刷新才看见你已经发了
by Mamba_End @ 2024-11-03 09:14:42
@ManZhouJi 那你发评测记录吧