是数据问题吗我用cin得了满分,建议加强数据

P11228 [CSP-J 2024] 地图探险

wenchenyu @ 2024-10-26 21:20:52

#include<iostream>
#include<cstdio>

using namespace std;
int t;
char c[1010][1010];
bool vis[1010][1010];
void dfs(int n,int m,int k,int x,int y,int d){
    vis[x][y]=1;
    if(k==0) return;
    else if(d==0&&c[x][y+1]!='x'&&y+1<=m) dfs(n,m,k-1,x,y+1,d);
    else if(d==1&&c[x+1][y]!='x'&&x+1<=n) dfs(n,m,k-1,x+1,y,d);
    else if(d==2&&c[x][y-1]!='x'&&y-1>=1) dfs(n,m,k-1,x,y-1,d);
    else if(d==3&&c[x-1][y]!='x'&&x-1>=1) dfs(n,m,k-1,x-1,y,d);
    else dfs(n,m,k-1,x,y,(d+1)%4);
}
int main(){
    cin>>t;
    for(int i=1;i<=t;i++){
        int n,m,k,x,y,d;
        cin>>n>>m>>k>>x>>y>>d;
        for(int i=1;i<=n;i++){
            for(int j=1;j<=m;j++) vis[i][j]=0;
        }
        for(int i=1;i<=n;i++){
            for(int j=1;j<=m;j++) cin>>c[i][j];
        }
        dfs(n,m,k,x,y,d);
        int ans=0;
        for(int i=1;i<=n;i++){
            for(int j=1;j<=m;j++){
                if(vis[i][j]==1) ans++;
            }
        }
        cout<<ans<<endl;
    }
    return 0;
}

by sikunran @ 2024-10-26 21:21:49

???你的意思是cin不能得满分?!?!?!


by Bigtanks10 @ 2024-10-26 21:31:38

dfs空间会爆吧


by wenchenyu @ 2024-10-26 21:33:54

@sikunran 输入这么庞大cin会超时吧


by wenchenyu @ 2024-10-26 21:36:08

@Bigtanks10 其实是个模拟


by zhang_hengyuan @ 2024-10-26 21:38:09

@wenchenyu 不会吧,我用的cin。说评测机CPU是8700K,不会太差罢。考试的时候第五样例走了1.0几秒(CPU是上古速龙),希望别卡


by Bigtanks10 @ 2024-10-26 21:38:19

我考场用的Dfs,最后一个爆了


by YYPanda233 @ 2024-10-26 21:39:29

@zhang_hengyuan 我是0.95s(


by sikunran @ 2024-10-27 08:46:24

@zhang_hengyuan 我考场第五样例0.7s过了,也没多想


|