답안 #101572

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
101572 2019-03-19T04:35:22 Z dantoh000 Tracks in the Snow (BOI13_tracks) C++14
82.5 / 100
2000 ms 91224 KB
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> ii;
int dx[] = {1,0,-1,0}, dy[] = {0,1,0,-1};
typedef pair<int,ii> iii;
int main(){
    int h,w;
    scanf("%d%d",&h,&w);
    char grid[h][w];
    int nonempty = 0;
    for (int i = 0; i < h; i++){
        for (int j = 0; j < w; j++){
            scanf(" %c",&grid[i][j]);
            if (grid[i][j] != '.') nonempty++;
        }
    }
    int num = 0;
    int vis[h][w];
    int ans = 1;
    char a = grid[0][0];
    char b = a^'F'^'R';
    memset(vis,0,sizeof(vis));
    priority_queue<iii,vector<iii>,greater<iii> > pq;
    pq.push(iii(1,ii(0,0)));
    vis[0][0] = 1;
    while(pq.size()){
        iii cur = pq.top(); pq.pop();
        int d = cur.first, x = cur.second.first, y = cur.second.second;
        for (int k = 0; k < 4; k++){
            int nx = x + dx[k], ny = y + dy[k];
            if (nx >= 0 && nx < h && ny >= 0 && ny < w && vis[nx][ny] == 0 && grid[nx][ny] != '.'){
                if (grid[nx][ny] == grid[x][y]){
                    vis[nx][ny] = vis[x][y];
                }
                else{
                    vis[nx][ny] = vis[x][y]+1;
                }
                ans = max(ans,vis[nx][ny]);
                //printf("%d %d %d\n",vis[nx][ny],nx,ny);
                pq.push(iii(vis[nx][ny],ii(nx,ny)));
            }
        }
    }
    printf("%d",ans);


}

Compilation message

tracks.cpp: In function 'int main()':
tracks.cpp:28:13: warning: unused variable 'd' [-Wunused-variable]
         int d = cur.first, x = cur.second.first, y = cur.second.second;
             ^
tracks.cpp:17:9: warning: unused variable 'num' [-Wunused-variable]
     int num = 0;
         ^~~
tracks.cpp:21:10: warning: unused variable 'b' [-Wunused-variable]
     char b = a^'F'^'R';
          ^
tracks.cpp:8: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:13:18: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
             scanf(" %c",&grid[i][j]);
             ~~~~~^~~~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 66 ms 1656 KB Output is correct
2 Correct 2 ms 256 KB Output is correct
3 Correct 3 ms 256 KB Output is correct
4 Correct 52 ms 1408 KB Output is correct
5 Correct 10 ms 768 KB Output is correct
6 Correct 2 ms 256 KB Output is correct
7 Correct 3 ms 384 KB Output is correct
8 Correct 3 ms 384 KB Output is correct
9 Correct 4 ms 384 KB Output is correct
10 Correct 10 ms 656 KB Output is correct
11 Correct 11 ms 752 KB Output is correct
12 Correct 25 ms 896 KB Output is correct
13 Correct 10 ms 768 KB Output is correct
14 Correct 11 ms 768 KB Output is correct
15 Correct 60 ms 1656 KB Output is correct
16 Correct 64 ms 1664 KB Output is correct
17 Correct 34 ms 1536 KB Output is correct
18 Correct 40 ms 1408 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 512 KB Output is correct
2 Correct 258 ms 8184 KB Output is correct
3 Correct 1371 ms 78736 KB Output is correct
4 Correct 371 ms 18708 KB Output is correct
5 Correct 698 ms 44424 KB Output is correct
6 Execution timed out 2043 ms 91224 KB Time limit exceeded
7 Correct 6 ms 512 KB Output is correct
8 Correct 5 ms 640 KB Output is correct
9 Correct 9 ms 768 KB Output is correct
10 Correct 4 ms 512 KB Output is correct
11 Correct 6 ms 512 KB Output is correct
12 Correct 4 ms 384 KB Output is correct
13 Correct 191 ms 8056 KB Output is correct
14 Correct 115 ms 4728 KB Output is correct
15 Correct 75 ms 5240 KB Output is correct
16 Correct 100 ms 3448 KB Output is correct
17 Correct 632 ms 20272 KB Output is correct
18 Correct 385 ms 19944 KB Output is correct
19 Correct 360 ms 18772 KB Output is correct
20 Correct 293 ms 17124 KB Output is correct
21 Correct 1024 ms 46080 KB Output is correct
22 Correct 700 ms 44536 KB Output is correct
23 Correct 1102 ms 38396 KB Output is correct
24 Correct 693 ms 44832 KB Output is correct
25 Correct 1571 ms 78636 KB Output is correct
26 Execution timed out 2021 ms 60252 KB Time limit exceeded
27 Execution timed out 2062 ms 80348 KB Time limit exceeded
28 Execution timed out 2075 ms 91036 KB Time limit exceeded
29 Execution timed out 2048 ms 90984 KB Time limit exceeded
30 Execution timed out 2025 ms 89612 KB Time limit exceeded
31 Execution timed out 2102 ms 51568 KB Time limit exceeded
32 Execution timed out 2074 ms 80248 KB Time limit exceeded