Submission #867990

# Submission time Handle Problem Language Result Execution time Memory
867990 2023-10-30T06:02:38 Z TAhmed33 Stranded Far From Home (BOI22_island) C++
0 / 100
1000 ms 604 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;
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++) {
		memset(vis, 0, sizeof(vis));
		vis[i] = 1; sze = cnt[i];
		for (int j = 1; j <= n; j++) {
			for (int k = 1; k <= n; k++) {
				if (!vis[k]) continue;
				for (auto d : adj[k]) {
					if (vis[d]) continue;
					if (sze >= cnt[d]) {
						sze += cnt[d];
						vis[d] = 1;
					}
				}
			}
		}
		cout << (sze == l);
	}
	cout << '\n';
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Execution timed out 1087 ms 348 KB Time limit exceeded
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Runtime error 5 ms 604 KB Execution killed with signal 11
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
2 Runtime error 5 ms 604 KB Execution killed with signal 11
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Runtime error 5 ms 604 KB Execution killed with signal 11
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Execution timed out 1087 ms 348 KB Time limit exceeded
5 Halted 0 ms 0 KB -