답안 #953583

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
953583 2024-03-26T09:31:44 Z roshanVerma Tracks in the Snow (BOI13_tracks) C++17
2.1875 / 100
2000 ms 923192 KB
#include<bits/stdc++.h>
using namespace std;

const int N = 4020;
int foxVis[N][N], rabbitVis[N][N];
int h,w,fox;
string forest[N];

void dfs( int x, int y ){
	if( x < 0 || x >= h || y < 0 || y >= w || forest[h][w] == '.' ) return;
	if( fox ){
		if( foxVis[x][y] == 1 ) return;
		foxVis[x][y] = 1;
	}else{
		if( rabbitVis[x][y] == 1 ) return;
		rabbitVis[x][y] = 1;
	}
	dfs(x+1,y);
	dfs(x-1,y);
	dfs(x,y+1);
	dfs(x,y-1);
}

int main(){
	cin >> h >> w;
	for( int i = 0 ; i < h ; i++ ) cin >> forest[i];

	int f = 0, r = 0;
	for( int i = 0 ; i < h ; i++ ){
		for( int j = 0 ; j < w ; j++ ){
			if( forest[i][j] == 'F' ) f = 1;
			else if( forest[i][j] == 'R' ) r = 1;
		}
	}

	int ans = 0, ans1 = 0, ans2 = 0;
	for( int i = 0 ; i < h ; i++ ){
		for( int j = 0 ; j < w ; j++ ){
			if( forest[i][j] == '.' || rabbitVis[i][j] ) continue;
			ans1++;
			dfs(i,j);
		}
	}

	fox = 1;
	for( int i = 0 ; i < h ; i++ ){
		for( int j = 0 ; j < w ; j++ ){
			if( forest[i][j] == '.' || foxVis[i][j] ) continue;
			ans2++;
			dfs(i,j);
		}
	}

	if( f ) ans += ans2;
	if( r ) ans += ans1;

	cout << ans << endl;

	return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Incorrect 34 ms 18272 KB Output isn't correct
2 Incorrect 1 ms 604 KB Output isn't correct
3 Incorrect 1 ms 1116 KB Output isn't correct
4 Incorrect 17 ms 13120 KB Output isn't correct
5 Incorrect 8 ms 7512 KB Output isn't correct
6 Incorrect 1 ms 564 KB Output isn't correct
7 Incorrect 1 ms 1116 KB Output isn't correct
8 Incorrect 1 ms 1116 KB Output isn't correct
9 Incorrect 2 ms 1884 KB Output isn't correct
10 Incorrect 6 ms 6300 KB Output isn't correct
11 Incorrect 4 ms 4308 KB Output isn't correct
12 Incorrect 8 ms 7772 KB Output isn't correct
13 Incorrect 8 ms 7516 KB Output isn't correct
14 Incorrect 10 ms 7516 KB Output isn't correct
15 Incorrect 27 ms 18780 KB Output isn't correct
16 Incorrect 25 ms 18192 KB Output isn't correct
17 Incorrect 25 ms 18000 KB Output isn't correct
18 Incorrect 17 ms 13148 KB Output isn't correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 23 ms 33880 KB Output isn't correct
2 Incorrect 179 ms 99516 KB Output isn't correct
3 Execution timed out 2062 ms 914464 KB Time limit exceeded
4 Incorrect 470 ms 231772 KB Output isn't correct
5 Incorrect 967 ms 537700 KB Output isn't correct
6 Incorrect 1876 ms 922728 KB Output isn't correct
7 Incorrect 19 ms 35412 KB Output isn't correct
8 Incorrect 19 ms 33884 KB Output isn't correct
9 Incorrect 5 ms 3932 KB Output isn't correct
10 Incorrect 3 ms 2396 KB Output isn't correct
11 Incorrect 19 ms 34472 KB Output isn't correct
12 Incorrect 3 ms 3164 KB Output isn't correct
13 Incorrect 168 ms 99896 KB Output isn't correct
14 Incorrect 94 ms 59748 KB Output isn't correct
15 Incorrect 106 ms 65880 KB Output isn't correct
16 Incorrect 66 ms 40016 KB Output isn't correct
17 Incorrect 427 ms 250280 KB Output isn't correct
18 Incorrect 465 ms 247324 KB Output isn't correct
19 Incorrect 415 ms 231996 KB Output isn't correct
20 Incorrect 368 ms 212820 KB Output isn't correct
21 Incorrect 1000 ms 556180 KB Output isn't correct
22 Incorrect 953 ms 537576 KB Output isn't correct
23 Incorrect 832 ms 459960 KB Output isn't correct
24 Incorrect 1022 ms 544316 KB Output isn't correct
25 Incorrect 1827 ms 922844 KB Output isn't correct
26 Correct 1333 ms 711208 KB Output is correct
27 Incorrect 1811 ms 923128 KB Output isn't correct
28 Incorrect 1822 ms 923128 KB Output isn't correct
29 Incorrect 1794 ms 923192 KB Output isn't correct
30 Incorrect 1761 ms 904544 KB Output isn't correct
31 Incorrect 1156 ms 604568 KB Output isn't correct
32 Incorrect 1800 ms 923136 KB Output isn't correct