Submission #101468

# Submission time Handle Problem Language Result Execution time Memory
101468 2019-03-19T02:49:45 Z rainy Tracks in the Snow (BOI13_tracks) C++14
0 / 100
2000 ms 1049600 KB
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<vector>
#include<utility>
#include<queue>
#define INF 1000000000
using namespace std;
typedef vector<int> vi;
typedef pair<int,int>ii;
int H,W;
char X;
int dx[]={0,1,0,-1},dy[]={1,0,-1,0};

int tis(vector<vi> x, int ani){
    queue<ii>q;q.push(ii(0,0));
    x[0][0]=-1;
    bool vis[H+5][W+5]={false};
    vis[0][0]=true;
    while(!q.empty()){
        int x1=q.front().first,y1=q.front().second;
        q.pop();
        for(int k=0;k<4;k++){
            int nx=x1+dx[k],ny=y1+dy[k];
            if(0<=nx&&nx<H&&0<=ny&&ny<W){
                if(!vis[nx][ny]){
                    if(x[nx][ny]==-1||x[nx][ny]==ani){
                        vis[nx][ny]=true;
                        x[nx][ny]=-1;
                        q.push(ii(nx,ny));
                    }
                }
            }
        }
    }
    if(!vis[H-1][W-1])return INF;
    bool isDone=true;
    for(int i=0;i<H;i++){
        for(int j=0;j<W;j++){
            if(x[i][j]==1||x[i][j]==2){
                isDone=false;break;
            }
        }
        if(isDone)break;
    }
    if(isDone)return 0;
    return 1+min(tis(x,1),tis(x,2));
}

int main(){
    scanf("%d%d",&H,&W);
    vector<vi> gr(H);
    for(int i=0;i<H;i++){
        vi xyz(W);
        for(int j=0;j<W;j++){
            xyz[j]=-1;
        }
        gr[i]=xyz;
    }
    for(int i=0;i<H;i++){
        for(int j=0;j<W;j++){
            scanf(" %c",&X);
            if(X=='.')gr[i][j]=0;
            if(X=='F')gr[i][j]=1;
            if(X=='R')gr[i][j]=2;
        }
    }
    for(int i=0;i<H;i++){
        for(int j=0;j<W;j++){
            printf("%d",gr[i][j]);
        }
        printf("\n");
    }
    printf("%d\n",1+tis(gr,gr[0][0]));
    return 0;
}

Compilation message

tracks.cpp: In function 'int main()':
tracks.cpp:51:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d%d",&H,&W);
     ~~~~~^~~~~~~~~~~~~~
tracks.cpp:62:18: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
             scanf(" %c",&X);
             ~~~~~^~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Runtime error 1731 ms 1049600 KB Execution killed with signal 9 (could be triggered by violating memory limits)
2 Runtime error 1327 ms 1049600 KB Execution killed with signal 9 (could be triggered by violating memory limits)
3 Runtime error 1854 ms 1049600 KB Execution killed with signal 9 (could be triggered by violating memory limits)
4 Execution timed out 2066 ms 382756 KB Time limit exceeded
5 Incorrect 17 ms 1920 KB Output isn't correct
6 Runtime error 1377 ms 1049600 KB Execution killed with signal 9 (could be triggered by violating memory limits)
7 Runtime error 1720 ms 1049600 KB Execution killed with signal 9 (could be triggered by violating memory limits)
8 Execution timed out 2091 ms 537848 KB Time limit exceeded
9 Incorrect 3 ms 384 KB Output isn't correct
10 Runtime error 1162 ms 1049600 KB Execution killed with signal 9 (could be triggered by violating memory limits)
11 Execution timed out 2087 ms 405880 KB Time limit exceeded
12 Runtime error 1194 ms 1049600 KB Execution killed with signal 9 (could be triggered by violating memory limits)
13 Incorrect 19 ms 2048 KB Output isn't correct
14 Incorrect 17 ms 1920 KB Output isn't correct
15 Runtime error 1178 ms 1049600 KB Execution killed with signal 9 (could be triggered by violating memory limits)
16 Runtime error 1562 ms 1049600 KB Execution killed with signal 9 (could be triggered by violating memory limits)
17 Runtime error 1135 ms 1049600 KB Execution killed with signal 9 (could be triggered by violating memory limits)
18 Execution timed out 2076 ms 426872 KB Time limit exceeded
# Verdict Execution time Memory Grader output
1 Incorrect 12 ms 1024 KB Output isn't correct
2 Runtime error 1283 ms 1049600 KB Execution killed with signal 9 (could be triggered by violating memory limits)
3 Execution timed out 2060 ms 79756 KB Time limit exceeded
4 Incorrect 636 ms 72312 KB Output isn't correct
5 Incorrect 1412 ms 91384 KB Output isn't correct
6 Execution timed out 2053 ms 77304 KB Time limit exceeded
7 Incorrect 12 ms 1152 KB Output isn't correct
8 Incorrect 11 ms 1144 KB Output isn't correct
9 Runtime error 1864 ms 1049600 KB Execution killed with signal 9 (could be triggered by violating memory limits)
10 Incorrect 8 ms 640 KB Output isn't correct
11 Incorrect 12 ms 1152 KB Output isn't correct
12 Incorrect 6 ms 512 KB Output isn't correct
13 Runtime error 1240 ms 1049600 KB Execution killed with signal 9 (could be triggered by violating memory limits)
14 Runtime error 1307 ms 1049600 KB Execution killed with signal 9 (could be triggered by violating memory limits)
15 Runtime error 1191 ms 1049600 KB Execution killed with signal 9 (could be triggered by violating memory limits)
16 Runtime error 1152 ms 1049600 KB Execution killed with signal 9 (could be triggered by violating memory limits)
17 Runtime error 1710 ms 1049600 KB Execution killed with signal 9 (could be triggered by violating memory limits)
18 Runtime error 1633 ms 1049600 KB Execution killed with signal 9 (could be triggered by violating memory limits)
19 Incorrect 552 ms 72312 KB Output isn't correct
20 Incorrect 442 ms 36132 KB Output isn't correct
21 Execution timed out 2100 ms 828648 KB Time limit exceeded
22 Incorrect 1208 ms 90360 KB Output isn't correct
23 Execution timed out 2109 ms 819552 KB Time limit exceeded
24 Incorrect 1338 ms 91896 KB Output isn't correct
25 Execution timed out 2041 ms 74000 KB Time limit exceeded
26 Execution timed out 2041 ms 122032 KB Time limit exceeded
27 Execution timed out 2017 ms 75976 KB Time limit exceeded
28 Execution timed out 2041 ms 78240 KB Time limit exceeded
29 Execution timed out 2069 ms 76280 KB Time limit exceeded
30 Execution timed out 2053 ms 77304 KB Time limit exceeded
31 Execution timed out 2109 ms 811484 KB Time limit exceeded
32 Execution timed out 2039 ms 78456 KB Time limit exceeded