답안 #742275

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
742275 2023-05-16T03:54:09 Z irmuun Tracks in the Snow (BOI13_tracks) C++17
47.5 / 100
2000 ms 1035556 KB
#include<bits/stdc++.h>
 
using namespace std;
 
#define pb push_back
#define ll long long
#define ff first
#define ss second
#define all(s) s.begin(),s.end()

int h,w,cur;
string s[4005];
void dfs(int i,int j,char c){
    cur++;
    s[i][j]=(c=='R'?'F':'R');
    if(i>0&&s[i-1][j]==c){
        dfs(i-1,j,c);
    }
    if(i<h-1&&s[i+1][j]==c){
        dfs(i+1,j,c);
    }
    if(j>0&&s[i][j-1]==c){
        dfs(i,j-1,c);
    }
    if(j<w-1&&s[i][j+1]==c){
        dfs(i,j+1,c);
    }
}
 
int main(){
    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    cin>>h>>w;
    int cnt=0;
    for(int i=0;i<h;i++){
        cin>>s[i];
        for(int j=0;j<w;j++){
            if(s[i][j]!='.'){
                cnt++;
            }
        }
    }
    int ans=1;
    cur=0;
    dfs(0,0,s[0][0]);
    while(cur<cnt){
        cur=0;
        dfs(0,0,s[0][0]);
        ans++;
    }
    cout<<ans;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 119 ms 13100 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 1 ms 468 KB Output is correct
4 Correct 16 ms 10304 KB Output is correct
5 Correct 23 ms 1020 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 1 ms 724 KB Output is correct
9 Correct 1 ms 468 KB Output is correct
10 Correct 30 ms 948 KB Output is correct
11 Correct 3 ms 2900 KB Output is correct
12 Correct 28 ms 4436 KB Output is correct
13 Correct 21 ms 1024 KB Output is correct
14 Correct 21 ms 980 KB Output is correct
15 Correct 193 ms 2892 KB Output is correct
16 Correct 122 ms 13104 KB Output is correct
17 Correct 173 ms 3532 KB Output is correct
18 Correct 15 ms 10304 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 602 ms 1160 KB Output is correct
2 Execution timed out 2067 ms 10156 KB Time limit exceeded
3 Execution timed out 2007 ms 19784 KB Time limit exceeded
4 Execution timed out 2058 ms 14904 KB Time limit exceeded
5 Execution timed out 2044 ms 11468 KB Time limit exceeded
6 Execution timed out 2118 ms 967908 KB Time limit exceeded
7 Correct 347 ms 952 KB Output is correct
8 Correct 643 ms 1116 KB Output is correct
9 Correct 62 ms 1228 KB Output is correct
10 Correct 88 ms 552 KB Output is correct
11 Correct 87 ms 716 KB Output is correct
12 Correct 697 ms 1176 KB Output is correct
13 Execution timed out 2056 ms 10752 KB Time limit exceeded
14 Execution timed out 2070 ms 6836 KB Time limit exceeded
15 Execution timed out 2057 ms 4124 KB Time limit exceeded
16 Execution timed out 2049 ms 5692 KB Time limit exceeded
17 Execution timed out 2050 ms 19924 KB Time limit exceeded
18 Execution timed out 2041 ms 9956 KB Time limit exceeded
19 Execution timed out 2051 ms 17944 KB Time limit exceeded
20 Execution timed out 2049 ms 8312 KB Time limit exceeded
21 Execution timed out 2011 ms 20324 KB Time limit exceeded
22 Execution timed out 2039 ms 19748 KB Time limit exceeded
23 Execution timed out 2029 ms 27792 KB Time limit exceeded
24 Execution timed out 2033 ms 19980 KB Time limit exceeded
25 Execution timed out 2077 ms 34952 KB Time limit exceeded
26 Correct 654 ms 792660 KB Output is correct
27 Execution timed out 2127 ms 1035556 KB Time limit exceeded
28 Execution timed out 2136 ms 982664 KB Time limit exceeded
29 Execution timed out 2131 ms 1001200 KB Time limit exceeded
30 Execution timed out 2133 ms 1013252 KB Time limit exceeded
31 Execution timed out 2028 ms 194284 KB Time limit exceeded
32 Execution timed out 2070 ms 559524 KB Time limit exceeded