답안 #1026631

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1026631 2024-07-18T08:46:46 Z kkkkkkkk Tracks in the Snow (BOI13_tracks) C++14
82.5 / 100
2000 ms 105260 KB
#include <bits/stdc++.h>
 
using namespace std;
 
int dr[]={+1, 0, -1, 0};
int dc[]={0, +1, 0, -1};
 
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    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 123 ms 2076 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Correct 1 ms 388 KB Output is correct
4 Correct 70 ms 2072 KB Output is correct
5 Correct 8 ms 860 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 2 ms 348 KB Output is correct
9 Correct 1 ms 464 KB Output is correct
10 Correct 11 ms 604 KB Output is correct
11 Correct 16 ms 856 KB Output is correct
12 Correct 44 ms 1116 KB Output is correct
13 Correct 7 ms 860 KB Output is correct
14 Correct 7 ms 856 KB Output is correct
15 Correct 108 ms 1920 KB Output is correct
16 Correct 149 ms 2232 KB Output is correct
17 Correct 40 ms 1628 KB Output is correct
18 Correct 67 ms 1876 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 600 KB Output is correct
2 Correct 272 ms 8248 KB Output is correct
3 Correct 907 ms 79020 KB Output is correct
4 Correct 243 ms 18940 KB Output is correct
5 Correct 254 ms 44560 KB Output is correct
6 Execution timed out 2029 ms 105260 KB Time limit exceeded
7 Correct 3 ms 604 KB Output is correct
8 Correct 3 ms 604 KB Output is correct
9 Correct 14 ms 860 KB Output is correct
10 Correct 1 ms 604 KB Output is correct
11 Correct 1 ms 604 KB Output is correct
12 Correct 1 ms 348 KB Output is correct
13 Correct 259 ms 8252 KB Output is correct
14 Correct 171 ms 4952 KB Output is correct
15 Correct 23 ms 5208 KB Output is correct
16 Correct 169 ms 3732 KB Output is correct
17 Correct 709 ms 20536 KB Output is correct
18 Correct 104 ms 20048 KB Output is correct
19 Correct 239 ms 18928 KB Output is correct
20 Correct 238 ms 17232 KB Output is correct
21 Correct 559 ms 46160 KB Output is correct
22 Correct 311 ms 44584 KB Output is correct
23 Correct 1401 ms 38480 KB Output is correct
24 Correct 254 ms 44884 KB Output is correct
25 Correct 444 ms 78896 KB Output is correct
26 Execution timed out 2037 ms 60496 KB Time limit exceeded
27 Execution timed out 2031 ms 80312 KB Time limit exceeded
28 Execution timed out 2083 ms 104204 KB Time limit exceeded
29 Execution timed out 2035 ms 103700 KB Time limit exceeded
30 Execution timed out 2053 ms 101896 KB Time limit exceeded
31 Execution timed out 2050 ms 54108 KB Time limit exceeded
32 Execution timed out 2048 ms 80228 KB Time limit exceeded