답안 #867992

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
867992 2023-10-30T06:21:12 Z TAhmed33 Stranded Far From Home (BOI22_island) C++
10 / 100
363 ms 852 KB
#include <bits/stdc++.h>
using namespace std;
#define int long long
const int MAXN = 2e3 + 25;
vector <int> adj[MAXN];
int cnt[MAXN];
bool vis[MAXN];
int sze;
signed 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++) {
		sze = cnt[i]; memset(vis, 0, sizeof(vis));
		set <pair <int, int>> dd; vis[i] = 1;
		for (auto j : adj[i]) dd.insert({cnt[j], j});
		while (!dd.empty()) {
			auto g = *(dd.begin());
			if (g.first > sze) break;
			sze += g.first;
			dd.erase(g); vis[g.second] = 1;
			for (auto j : adj[g.second]) {
				if (!vis[j]) dd.insert({cnt[j], j});
			}
		}
		cout << (sze == l);
	}
	cout << '\n';
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 243 ms 580 KB Output is correct
5 Correct 225 ms 604 KB Output is correct
6 Correct 363 ms 604 KB Output is correct
7 Correct 235 ms 852 KB Output is correct
8 Correct 188 ms 604 KB Output is correct
9 Correct 341 ms 648 KB Output is correct
10 Correct 95 ms 604 KB Output is correct
11 Correct 96 ms 584 KB Output is correct
12 Correct 119 ms 600 KB Output is correct
13 Correct 221 ms 596 KB Output is correct
14 Correct 123 ms 576 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Runtime error 3 ms 604 KB Execution killed with signal 11
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Runtime error 3 ms 604 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 3 ms 600 KB Execution killed with signal 11
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 243 ms 580 KB Output is correct
5 Correct 225 ms 604 KB Output is correct
6 Correct 363 ms 604 KB Output is correct
7 Correct 235 ms 852 KB Output is correct
8 Correct 188 ms 604 KB Output is correct
9 Correct 341 ms 648 KB Output is correct
10 Correct 95 ms 604 KB Output is correct
11 Correct 96 ms 584 KB Output is correct
12 Correct 119 ms 600 KB Output is correct
13 Correct 221 ms 596 KB Output is correct
14 Correct 123 ms 576 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
17 Runtime error 3 ms 604 KB Execution killed with signal 11
18 Halted 0 ms 0 KB -