답안 #876349

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
876349 2023-11-21T15:21:08 Z vjudge1 Tracks in the Snow (BOI13_tracks) C++17
13.3333 / 100
1438 ms 1048576 KB
#include <iostream>
#include <vector>

#define pb push_back
#define endl '\n'

using namespace std;

const int MAXN = 3e7+100;

vector<int> adj[MAXN];
char tp[MAXN];

int h, w, n;
string mat[4010];

int cnt;
bool used[MAXN];

void dfs(int v, int ld){
	// cout << ld << ' ' << v << endl;
	used[v] = 1;

	for(int u : adj[v]){
		if(used[u] || tp[u] == '.') continue;
		if(tp[u] == tp[v] || tp[u] == '-' || tp[v] == '-') dfs(u, ld);
		else if(tp[v] != '-'){
			adj[u].pb(n+ld);
			adj[n+ld].pb(u);

			// cout << u << "<->" << n+ld << endl;
		}
	}
}

int main(){
	ios::sync_with_stdio(0);cin.tie(0);


	cin >> h >> w;
	n = h*w;

	for(int i=0;i<h; i++) cin >> mat[i];

	for(int i=0; i<h; i++){
		for(int j=0; j<w; j++){
			if(i < (h-1)){
				adj[(i*w) + j].pb((i+1)*w + j);
				adj[(i+1)*w + j].pb((i*w) + j);
			}

			if(j < (w-1)){
				adj[(i*w) + j].pb((i*w) +j+1);
				adj[(i*w) +j+1].pb((i*w) + j);
			}
			
			tp[i*w + j] = mat[i][j];
		}
	}

	for(int i=0; i<n; i++){
		if(used[i] || tp[i] == '.') continue;

		used[i] = 1;	
		tp[cnt + n] = '-';
		dfs(i, cnt);

		cnt++;

	}


	cout << cnt << endl;

	return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 319 ms 719200 KB Output is correct
2 Incorrect 246 ms 706164 KB Output isn't correct
3 Incorrect 298 ms 706280 KB Output isn't correct
4 Correct 367 ms 714408 KB Output is correct
5 Incorrect 318 ms 709540 KB Output isn't correct
6 Incorrect 263 ms 708176 KB Output isn't correct
7 Incorrect 261 ms 706320 KB Output isn't correct
8 Correct 268 ms 706564 KB Output is correct
9 Incorrect 247 ms 706648 KB Output isn't correct
10 Incorrect 263 ms 708876 KB Output isn't correct
11 Correct 291 ms 708448 KB Output is correct
12 Correct 266 ms 710928 KB Output is correct
13 Incorrect 258 ms 709544 KB Output isn't correct
14 Incorrect 305 ms 709692 KB Output isn't correct
15 Correct 337 ms 718868 KB Output is correct
16 Correct 297 ms 719068 KB Output is correct
17 Incorrect 296 ms 716816 KB Output isn't correct
18 Correct 264 ms 714576 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 255 ms 708276 KB Output isn't correct
2 Incorrect 465 ms 774120 KB Output isn't correct
3 Runtime error 1269 ms 1048576 KB Execution killed with signal 9
4 Incorrect 709 ms 853048 KB Output isn't correct
5 Runtime error 1002 ms 1048576 KB Execution killed with signal 9
6 Runtime error 1065 ms 1048576 KB Execution killed with signal 9
7 Incorrect 159 ms 710068 KB Output isn't correct
8 Incorrect 160 ms 710364 KB Output isn't correct
9 Incorrect 157 ms 711012 KB Output isn't correct
10 Incorrect 152 ms 709724 KB Output isn't correct
11 Incorrect 161 ms 710344 KB Output isn't correct
12 Incorrect 160 ms 709380 KB Output isn't correct
13 Incorrect 375 ms 776396 KB Output isn't correct
14 Incorrect 273 ms 746476 KB Output isn't correct
15 Incorrect 392 ms 749140 KB Output isn't correct
16 Incorrect 248 ms 736836 KB Output isn't correct
17 Incorrect 740 ms 882556 KB Output isn't correct
18 Incorrect 792 ms 876176 KB Output isn't correct
19 Incorrect 660 ms 853552 KB Output isn't correct
20 Incorrect 560 ms 845396 KB Output isn't correct
21 Runtime error 973 ms 1048576 KB Execution killed with signal 9
22 Runtime error 977 ms 1048576 KB Execution killed with signal 9
23 Incorrect 1438 ms 1033748 KB Output isn't correct
24 Runtime error 1030 ms 1048576 KB Execution killed with signal 9
25 Runtime error 982 ms 1048576 KB Execution killed with signal 9
26 Runtime error 956 ms 1048576 KB Execution killed with signal 9
27 Runtime error 1018 ms 1048576 KB Execution killed with signal 9
28 Runtime error 1018 ms 1048576 KB Execution killed with signal 9
29 Runtime error 1002 ms 1048576 KB Execution killed with signal 9
30 Runtime error 1000 ms 1048576 KB Execution killed with signal 9
31 Runtime error 1026 ms 1048576 KB Execution killed with signal 9
32 Runtime error 1178 ms 1048576 KB Execution killed with signal 9