Submission #101500

# Submission time Handle Problem Language Result Execution time Memory
101500 2019-03-19T03:21:34 Z jamielim Tracks in the Snow (BOI13_tracks) C++14
49.6875 / 100
2000 ms 17784 KB
#include <bits/stdc++.h>
using namespace std;

int main(){
    int h,w;
    scanf("%d%d",&h,&w);
    char grid[h+5][w+5];
    for(int i=0;i<h;i++){
        scanf("%s",grid[i]);
    }
    int r=0,ttl=0;
    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
            if(grid[i][j]=='R'){r++;ttl++;}
            else if(grid[i][j]=='F')ttl++;
        }
    }
    int ans=1;
    queue<pair<int,int> > q;
    int dx[]={0,0,1,-1},dy[]={1,-1,0,0};
    while(r!=0&&r!=ttl){
        ans++;
        q.push(make_pair(0,0));
        if(grid[0][0]=='R'){
            while(!q.empty()){
                pair<int,int> cur=q.front();q.pop();
                for(int i=0;i<4;i++){
                    int nx=cur.first+dx[i],ny=cur.second+dy[i];
                    if(0<=nx&&nx<h&&0<=ny&&ny<w&&grid[nx][ny]=='R'){
                        grid[nx][ny]='F';
                        r--;
                        q.push(make_pair(nx,ny));
                    }
                }
            }
        }else{
            while(!q.empty()){
                pair<int,int> cur=q.front();q.pop();
                for(int i=0;i<4;i++){
                    int nx=cur.first+dx[i],ny=cur.second+dy[i];
                    if(0<=nx&&nx<h&&0<=ny&&ny<w&&grid[nx][ny]=='F'){
                        grid[nx][ny]='R';
                        r++;
                        q.push(make_pair(nx,ny));
                    }
                }
            }
        }
    }
    printf("%d",ans);
}

Compilation message

tracks.cpp: In function 'int main()':
tracks.cpp:6: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:9:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%s",grid[i]);
         ~~~~~^~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 129 ms 768 KB Output is correct
2 Correct 3 ms 384 KB Output is correct
3 Correct 3 ms 256 KB Output is correct
4 Correct 13 ms 512 KB Output is correct
5 Correct 37 ms 384 KB Output is correct
6 Correct 2 ms 256 KB Output is correct
7 Correct 3 ms 256 KB Output is correct
8 Correct 3 ms 256 KB Output is correct
9 Correct 4 ms 256 KB Output is correct
10 Correct 62 ms 448 KB Output is correct
11 Correct 5 ms 384 KB Output is correct
12 Correct 42 ms 512 KB Output is correct
13 Correct 37 ms 384 KB Output is correct
14 Correct 40 ms 384 KB Output is correct
15 Correct 356 ms 808 KB Output is correct
16 Correct 143 ms 888 KB Output is correct
17 Correct 253 ms 888 KB Output is correct
18 Correct 14 ms 640 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1014 ms 432 KB Output is correct
2 Execution timed out 2061 ms 2432 KB Time limit exceeded
3 Execution timed out 2037 ms 17784 KB Time limit exceeded
4 Execution timed out 2039 ms 5624 KB Time limit exceeded
5 Execution timed out 2061 ms 12152 KB Time limit exceeded
6 Execution timed out 2037 ms 16376 KB Time limit exceeded
7 Correct 714 ms 424 KB Output is correct
8 Correct 1045 ms 436 KB Output is correct
9 Correct 114 ms 504 KB Output is correct
10 Correct 278 ms 396 KB Output is correct
11 Correct 226 ms 436 KB Output is correct
12 Correct 1377 ms 388 KB Output is correct
13 Execution timed out 2045 ms 2020 KB Time limit exceeded
14 Execution timed out 2051 ms 1280 KB Time limit exceeded
15 Execution timed out 2023 ms 1408 KB Time limit exceeded
16 Execution timed out 2076 ms 1024 KB Time limit exceeded
17 Execution timed out 2054 ms 4344 KB Time limit exceeded
18 Execution timed out 2056 ms 4352 KB Time limit exceeded
19 Execution timed out 2048 ms 4344 KB Time limit exceeded
20 Execution timed out 2053 ms 3960 KB Time limit exceeded
21 Execution timed out 2031 ms 9720 KB Time limit exceeded
22 Execution timed out 2028 ms 11640 KB Time limit exceeded
23 Execution timed out 2041 ms 8056 KB Time limit exceeded
24 Execution timed out 2049 ms 11640 KB Time limit exceeded
25 Execution timed out 2052 ms 15992 KB Time limit exceeded
26 Correct 90 ms 12280 KB Output is correct
27 Correct 1990 ms 16120 KB Output is correct
28 Execution timed out 2020 ms 16256 KB Time limit exceeded
29 Execution timed out 2023 ms 16120 KB Time limit exceeded
30 Execution timed out 2025 ms 15836 KB Time limit exceeded
31 Execution timed out 2017 ms 10420 KB Time limit exceeded
32 Execution timed out 2041 ms 16120 KB Time limit exceeded