답안 #924209

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
924209 2024-02-08T16:25:51 Z absolutePi Tracks in the Snow (BOI13_tracks) C++17
100 / 100
607 ms 135676 KB
#include <bits/stdc++.h>

using namespace std;

const int N = 4000;
string snow[N];
int dept[N][N];
int h,w;

int mx[]={1,-1,0,0},my[]={0,0,1,-1};

bool inside(int x,int y){
    return (x>=0&&y>=0&&x<h&&y<w&&snow[x][y]!='.');
}

int main(){
    //ios::sync_with_stdio(false);
    //cin.tie(0);
    cin >> h >> w;
    for(int i=0;i<h;i++){
        cin >> snow[i];
    }
    deque<pair<int,int>> q;
    dept[0][0]=1;
    q.push_back({0,0});
    int ans=1;
    while(!q.empty()){
        auto curr = q.front();
        q.pop_front();
        ans=max(ans,dept[curr.first][curr.second]);
        for(int i=0;i<4;i++){
            int x=curr.first+mx[i];
            int y=curr.second+my[i];
            if(inside(x,y)&&dept[x][y]==0){
                if(snow[x][y]==snow[curr.first][curr.second]){
                    dept[x][y]=dept[curr.first][curr.second];
                    q.push_front({x,y});
                }
                else{
                    dept[x][y]=dept[curr.first][curr.second]+1;
                    q.push_back({x,y});
                }
            }
        }
    }
    cout << ans << '\n';
}   
# 결과 실행 시간 메모리 Grader output
1 Correct 11 ms 4184 KB Output is correct
2 Correct 0 ms 604 KB Output is correct
3 Correct 1 ms 604 KB Output is correct
4 Correct 6 ms 3676 KB Output is correct
5 Correct 3 ms 2140 KB Output is correct
6 Correct 0 ms 604 KB Output is correct
7 Correct 1 ms 604 KB Output is correct
8 Correct 1 ms 604 KB Output is correct
9 Correct 1 ms 860 KB Output is correct
10 Correct 3 ms 1680 KB Output is correct
11 Correct 2 ms 1628 KB Output is correct
12 Correct 6 ms 2160 KB Output is correct
13 Correct 3 ms 2140 KB Output is correct
14 Correct 3 ms 2140 KB Output is correct
15 Correct 10 ms 3932 KB Output is correct
16 Correct 11 ms 4124 KB Output is correct
17 Correct 9 ms 3932 KB Output is correct
18 Correct 7 ms 3676 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 8 ms 15964 KB Output is correct
2 Correct 45 ms 12632 KB Output is correct
3 Correct 337 ms 87972 KB Output is correct
4 Correct 93 ms 32696 KB Output is correct
5 Correct 215 ms 53312 KB Output is correct
6 Correct 607 ms 122604 KB Output is correct
7 Correct 10 ms 16480 KB Output is correct
8 Correct 7 ms 15964 KB Output is correct
9 Correct 2 ms 860 KB Output is correct
10 Correct 1 ms 580 KB Output is correct
11 Correct 8 ms 16220 KB Output is correct
12 Correct 1 ms 1116 KB Output is correct
13 Correct 45 ms 12688 KB Output is correct
14 Correct 26 ms 8796 KB Output is correct
15 Correct 24 ms 11092 KB Output is correct
16 Correct 20 ms 4956 KB Output is correct
17 Correct 119 ms 28572 KB Output is correct
18 Correct 98 ms 35412 KB Output is correct
19 Correct 88 ms 32448 KB Output is correct
20 Correct 77 ms 25424 KB Output is correct
21 Correct 192 ms 52308 KB Output is correct
22 Correct 214 ms 53196 KB Output is correct
23 Correct 219 ms 43448 KB Output is correct
24 Correct 191 ms 49436 KB Output is correct
25 Correct 472 ms 108840 KB Output is correct
26 Correct 366 ms 130656 KB Output is correct
27 Correct 497 ms 135676 KB Output is correct
28 Correct 579 ms 122444 KB Output is correct
29 Correct 577 ms 120868 KB Output is correct
30 Correct 539 ms 124672 KB Output is correct
31 Correct 437 ms 72936 KB Output is correct
32 Correct 453 ms 120856 KB Output is correct