답안 #867987

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
867987 2023-10-30T05:39:51 Z TAhmed33 Stranded Far From Home (BOI22_island) C++
0 / 100
7 ms 1112 KB
#include <bits/stdc++.h>
using namespace std;
const int MAXN = 2e3 + 25;
vector <int> adj[MAXN];
int cnt[MAXN];
bool vis[MAXN];
int sze;
void dfs (int pos) {
	vis[pos] = 1;
	for (auto j : adj[pos]) {
		if (vis[j]) continue;
		if (sze >= cnt[j]) {
			sze += cnt[j];
			dfs(j);
		}
	}
}
int main () {
	int n, m;
	cin >> n >> m;
	int l = 0;
	for (int i = 1; i <= n; i++) cin >> cnt[i], l += cnt[i];
	for (int i = 1; i <= m; i++) {
		int a, b;
		cin >> a >> b;
		adj[a].push_back(b);
		adj[b].push_back(a);
	}
	for (int i = 1; i <= n; i++) {
		sort(adj[i].begin(), adj[i].end(), [&] (int &a, int &b) {
			return cnt[a] < cnt[b];
		});
	}
	for (int i = 1; i <= n; i++) {
		sze = cnt[i]; memset(vis, 0, sizeof(vis));
		dfs(i);
		cout << (sze == l);
	}
	cout << '\n';
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Incorrect 2 ms 500 KB Output isn't correct
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Runtime error 5 ms 1112 KB Execution killed with signal 11
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Runtime error 5 ms 988 KB Execution killed with signal 11
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Runtime error 7 ms 1016 KB Execution killed with signal 11
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Incorrect 2 ms 500 KB Output isn't correct
5 Halted 0 ms 0 KB -