CCF,0分样例全过

P11228 [CSP-J 2024] 地图探险

Dz8897 @ 2024-11-05 21:57:53

//GZ-J00235
#include<bits/stdc++.h>
using namespace std;
int mp[10005][10005],mc[10005][10005];
int n=0,m=0,k=0,x=0,y=0,z=0,d=0,t=0,sum=0;
char ch;
int csh(){
    for(int j=0;j<=n+10;j++)
        for(int q=0;q<=m+10;q++){
            mp[j][q]=0;mc[j][q]=0;
        }

}
int yd(){
    //mp[x][y]=2;
    if(d==0){
        if(mp[x][y+1]==1&&x>=1&&x<=n&&y>=1&&y<=m){y++;mc[x][y]=2;}
        else d=(d+1)%4;
    }
    else if(d==1){
        if(mp[x+1][y]==1&&x>=1&&x<=n&&y>=1&&y<=m) {x++;mc[x][y]=2;}
        else d=(d+1)%4;
    }
    else if(d==2){//N
        if(mp[x][y-1]==1&&x>=1&&x<=n&&y>=1&&y<=m) {y--;mc[x][y]=2;}
        else d=(d+1)%4;
    }
    else if(d==3){
        if(mp[x-1][y]==1&&x>=1&&x<=n&&y>=1&&y<=m) {x--;mc[x][y]=2;}
        else d=(d+1)%4;
    }
    /*
    if(d==0){
        if(mp[x][y+1]==2&&x>=1&&x<=n&&y>=1&&y<=m) {y++;mp[x][y]=2;}
        else d=(d+1)%4;
    }
    else if(d==1){
        if(mp[x+1][y]==2&&x>=1&&x<=n&&y>=1&&y<=m) {x++;mp[x][y]=2;}
        else d=(d+1)%4;
    }
    else if(d==2){
        if(mp[x][y-1]==2&&x>=1&&x<=n&&y>=1&&y<=m) {y--;mp[x][y]=2;}
        else d=(d+1)%4;
    }
    else if(d==3){
        if(mp[x-1][y]==2&&x>=1&&x<=n&&y>=1&&y<=m) {x--;mp[x][y]=2;}
        else d=(d+1)%4;
    }*/
    //cout<<"F"<<x<<" "<<y<<" "<<d<<endl;
    mc[x][y]=2;
    return 0;
}
int main(){
    freopen("explore.in","r",stdin);
    freopen("explore.out","w",stdout);
    cin>>t;
    for(int i=1;i<=t;i++){
        n=0,m=0,k=0,x=0,y=0,z=0,d=0,sum=0;
        cin>>n>>m>>k;
        cin>>x>>y>>d;
        csh();
        mc[x][y]=2;
        for(int j=1;j<=n;j++){
            for(int q=1;q<=m;q++){
                cin>>ch;
                if(ch=='x') mp[j][q]=-1;
                if(ch=='.') mp[j][q]=1;
            }
        }
        for(int o=1;o<=k;o++){
            yd();
        }
        for(int j=1;j<=n;j++){
            for(int q=1;q<=m;q++){
                if(mc[j][q]==2) sum++;
            }
        }
        cout<<sum<<endl;
    }
    return 0;
}
/*
2
1 5 4
1 1 2
....x
5 5 20
1 1 0
.....
.xxx.
.x.x.
..xx.
x....
*/

by st2010 @ 2024-11-05 21:59:59

@Dz8897 把freopen去掉!!!!!!


by Dz8897 @ 2024-11-05 22:03:47

@st2010 是CCF0分


by ENJOY_AK @ 2024-11-05 22:05:47

@Dz8897 洛谷也0分吗


by st2010 @ 2024-11-05 22:07:55

@Dz8897 我来看看


by st2010 @ 2024-11-05 22:10:20

@ENJOY_AK 他代码一半超时一半超空间


by ENJOY_AK @ 2024-11-05 22:14:08

@Dz8897 建议去官网下个测试数据包,自测一下看看问题


by st2010 @ 2024-11-05 22:18:31

@ENJOY_AK 他样例全过


by ENJOY_AK @ 2024-11-05 22:19:48

@st2010 不是指样例,是说实际测试数据


by st2010 @ 2024-11-05 22:29:33

@ENJOY_AK RE是他空间开小了,然后他是暴力算法的,所以一个点都过不去TLE了......


by st2010 @ 2024-11-05 22:30:27

@ENJOY_AK @Dz8897 楼主重打吧.....


| 下一页