# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
101449 | 2019-03-19T02:25:10 Z | rocketninja7 | Tracks in the Snow (BOI13_tracks) | C++14 | 2000 ms | 106048 KB |
#include <cstdio> #include <vector> #include <queue> #include <algorithm> using namespace std; pair<int, int> dir[]={make_pair(0, -1), make_pair(1, 0), make_pair(0, 1), make_pair(-1, 0)}; int main(){ int H, W; scanf("%d%d", &H, &W); char grid[H][W+1]; for(int i=0;i<H;i++){ scanf("%s", &grid[i]); } int dist[H][W]; for(int i=0;i<H;i++){ for(int j=0;j<W;j++){ dist[i][j]=-1; } } dist[0][0]=1; priority_queue<pair<int, pair<int, int> > > proc; proc.push(make_pair(-1, make_pair(0, 0))); while(!proc.empty()){ int x=proc.top().second.first, y=proc.top().second.second; proc.pop(); for(int i=0;i<4;i++){ if(x+dir[i].first>-1&&x+dir[i].first<H&&y+dir[i].second>-1&&y+dir[i].second<W){ if(grid[x+dir[i].first][y+dir[i].second]!='.'){ if(dist[x+dir[i].first][y+dir[i].second]==-1){ if(grid[x+dir[i].first][y+dir[i].second]==grid[x][y]){ dist[x+dir[i].first][y+dir[i].second]=dist[x][y]; } else{ dist[x+dir[i].first][y+dir[i].second]=dist[x][y]+1; } proc.push(make_pair(-dist[x+dir[i].first][y+dir[i].second], make_pair(x+dir[i].first, y+dir[i].second))); } } } } } int ans=1; for(int i=0;i<H;i++){ for(int j=0;j<W;j++){ ans=max(ans, dist[i][j]); } } printf("%d", ans); return 0; }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 57 ms | 1920 KB | Output is correct |
2 | Correct | 2 ms | 384 KB | Output is correct |
3 | Correct | 3 ms | 384 KB | Output is correct |
4 | Correct | 41 ms | 1728 KB | Output is correct |
5 | Correct | 7 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 | 3 ms | 384 KB | Output is correct |
10 | Correct | 7 ms | 640 KB | Output is correct |
11 | Correct | 12 ms | 656 KB | Output is correct |
12 | Correct | 21 ms | 896 KB | Output is correct |
13 | Correct | 4 ms | 768 KB | Output is correct |
14 | Correct | 7 ms | 768 KB | Output is correct |
15 | Correct | 47 ms | 1912 KB | Output is correct |
16 | Correct | 52 ms | 1912 KB | Output is correct |
17 | Correct | 28 ms | 1664 KB | Output is correct |
18 | Correct | 45 ms | 1720 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 3 ms | 512 KB | Output is correct |
2 | Correct | 165 ms | 9556 KB | Output is correct |
3 | Correct | 492 ms | 84344 KB | Output is correct |
4 | Correct | 162 ms | 21116 KB | Output is correct |
5 | Correct | 235 ms | 47864 KB | Output is correct |
6 | Execution timed out | 2041 ms | 106048 KB | Time limit exceeded |
7 | Correct | 4 ms | 512 KB | Output is correct |
8 | Correct | 4 ms | 640 KB | Output is correct |
9 | Correct | 9 ms | 640 KB | Output is correct |
10 | Correct | 3 ms | 512 KB | Output is correct |
11 | Correct | 4 ms | 640 KB | Output is correct |
12 | Correct | 2 ms | 384 KB | Output is correct |
13 | Correct | 143 ms | 9292 KB | Output is correct |
14 | Correct | 81 ms | 5616 KB | Output is correct |
15 | Correct | 33 ms | 6124 KB | Output is correct |
16 | Correct | 66 ms | 4224 KB | Output is correct |
17 | Correct | 342 ms | 21624 KB | Output is correct |
18 | Correct | 123 ms | 21308 KB | Output is correct |
19 | Correct | 165 ms | 19840 KB | Output is correct |
20 | Correct | 114 ms | 18296 KB | Output is correct |
21 | Correct | 279 ms | 47892 KB | Output is correct |
22 | Correct | 218 ms | 50680 KB | Output is correct |
23 | Correct | 703 ms | 38520 KB | Output is correct |
24 | Correct | 183 ms | 45432 KB | Output is correct |
25 | Correct | 607 ms | 78564 KB | Output is correct |
26 | Correct | 1784 ms | 60564 KB | Output is correct |
27 | Execution timed out | 2024 ms | 81864 KB | Time limit exceeded |
28 | Execution timed out | 2031 ms | 103384 KB | Time limit exceeded |
29 | Execution timed out | 2059 ms | 91156 KB | Time limit exceeded |
30 | Execution timed out | 2027 ms | 89424 KB | Time limit exceeded |
31 | Execution timed out | 2056 ms | 51440 KB | Time limit exceeded |
32 | Execution timed out | 2044 ms | 80364 KB | Time limit exceeded |