답안 #1026590

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1026590 2024-07-18T08:21:42 Z vjudge1 Tracks in the Snow (BOI13_tracks) C++17
82.5 / 100
2000 ms 120232 KB
#include <bits/stdc++.h>

using namespace std;

int dr[]={+1, 0, -1, 0};
int dc[]={0, +1, 0, -1};

int main()
{
    int n, m;
    cin >> n >> m;
    char tracks[n][m];
    for (int i=0;i<n;i++)
        for (int j=0;j<m;j++)
            cin >> tracks[i][j];
    priority_queue<pair<int, pair<int,int> > > pq;
    pq.push({-1, {0,0}});
    int vis[n][m], rez=1;
    memset(vis, -1, sizeof(vis));
    while (!pq.empty()) {
        int r=pq.top().second.first, c=pq.top().second.second, dist=-pq.top().first;
        pq.pop();
        if (vis[r][c]!=-1) continue;
        vis[r][c]=dist;
        rez=max(rez, dist);
        for (int i=0;i<4;i++) {
            int nr=r+dr[i], nc=c+dc[i];
            if (nr>=0&&nc>=0&&nr<n&&nc<m&&tracks[nr][nc]!='.') {
                if (tracks[nr][nc]!=tracks[r][c]) pq.push({-(dist+1), {nr, nc}});
                else pq.push({-dist, {nr, nc}});
            }
        }
    }
    cout << rez;

    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 125 ms 2328 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 68 ms 2000 KB Output is correct
5 Correct 9 ms 860 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 1 ms 436 KB Output is correct
8 Correct 2 ms 348 KB Output is correct
9 Correct 1 ms 348 KB Output is correct
10 Correct 11 ms 704 KB Output is correct
11 Correct 17 ms 860 KB Output is correct
12 Correct 42 ms 1116 KB Output is correct
13 Correct 8 ms 812 KB Output is correct
14 Correct 8 ms 860 KB Output is correct
15 Correct 88 ms 2140 KB Output is correct
16 Correct 125 ms 2328 KB Output is correct
17 Correct 44 ms 1880 KB Output is correct
18 Correct 68 ms 2136 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 600 KB Output is correct
2 Correct 286 ms 9760 KB Output is correct
3 Correct 1139 ms 94828 KB Output is correct
4 Correct 273 ms 22352 KB Output is correct
5 Correct 472 ms 53376 KB Output is correct
6 Execution timed out 2037 ms 120096 KB Time limit exceeded
7 Correct 3 ms 604 KB Output is correct
8 Correct 3 ms 604 KB Output is correct
9 Correct 12 ms 964 KB Output is correct
10 Correct 2 ms 700 KB Output is correct
11 Correct 3 ms 604 KB Output is correct
12 Correct 1 ms 348 KB Output is correct
13 Correct 281 ms 9596 KB Output is correct
14 Correct 185 ms 5760 KB Output is correct
15 Correct 42 ms 6116 KB Output is correct
16 Correct 149 ms 4188 KB Output is correct
17 Correct 695 ms 24656 KB Output is correct
18 Correct 175 ms 23892 KB Output is correct
19 Correct 288 ms 22356 KB Output is correct
20 Correct 270 ms 20532 KB Output is correct
21 Correct 688 ms 55280 KB Output is correct
22 Correct 443 ms 53428 KB Output is correct
23 Correct 1499 ms 46024 KB Output is correct
24 Correct 407 ms 53960 KB Output is correct
25 Correct 779 ms 94548 KB Output is correct
26 Execution timed out 2039 ms 72528 KB Time limit exceeded
27 Execution timed out 2059 ms 95964 KB Time limit exceeded
28 Execution timed out 2044 ms 120232 KB Time limit exceeded
29 Execution timed out 2076 ms 120212 KB Time limit exceeded
30 Execution timed out 2056 ms 118912 KB Time limit exceeded
31 Execution timed out 2045 ms 65224 KB Time limit exceeded
32 Execution timed out 2065 ms 95940 KB Time limit exceeded