답안 #867994

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
867994 2023-10-30T06:23:58 Z TAhmed33 Stranded Far From Home (BOI22_island) C++
10 / 100
598 ms 524288 KB
#include <bits/stdc++.h>
using namespace std;
#define int long long
bool ok[200001];
vector <int> adj[200001];
int cnt[200001], sze[200001];
void dfs (int pos, int par) {
	sze[pos] = cnt[pos];
	for (auto j : adj[pos]) {
		if (j != par) {
			dfs(j, pos);
			sze[pos] += sze[j];
		}
	}
}
void dfs2 (int pos, int par) {
	if (par != -1) {
		if (sze[pos] < cnt[par]) return;
	}
	ok[pos] = 1;
	for (auto j : adj[pos]) if  (j != par) dfs2(j, pos);
}
signed main () {
	int n, m;
	cin >> n >> m;
	for (int i = 1; i <= n; i++) cin >> cnt[i];
	for (int i = 1; i < n; i++) {
		int a, b;
		cin >> a >> b;
		adj[a].push_back(b);
		adj[b].push_back(a);
	}
	dfs(1, -1);
	dfs2(1, -1);
	for (int i = 1; i <= n; i++) cout << ok[i];
}
# 결과 실행 시간 메모리 Grader output
1 Runtime error 285 ms 524288 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 8028 KB Output is correct
2 Correct 2 ms 8024 KB Output is correct
3 Correct 206 ms 24912 KB Output is correct
4 Correct 153 ms 23804 KB Output is correct
5 Correct 188 ms 19728 KB Output is correct
6 Correct 199 ms 20208 KB Output is correct
7 Correct 201 ms 20376 KB Output is correct
8 Correct 196 ms 20336 KB Output is correct
9 Correct 188 ms 21328 KB Output is correct
10 Correct 148 ms 19700 KB Output is correct
11 Correct 145 ms 20188 KB Output is correct
12 Correct 164 ms 18772 KB Output is correct
13 Correct 174 ms 30048 KB Output is correct
14 Correct 156 ms 30292 KB Output is correct
15 Correct 198 ms 31824 KB Output is correct
16 Correct 165 ms 31136 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 8028 KB Output is correct
2 Incorrect 199 ms 31136 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 8028 KB Output is correct
2 Runtime error 598 ms 524288 KB Execution killed with signal 9
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 285 ms 524288 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -