Submission #744917

# Submission time Handle Problem Language Result Execution time Memory
744917 2023-05-19T08:10:02 Z josanneo22 Stranded Far From Home (BOI22_island) C++17
0 / 100
1000 ms 17384 KB
#include <bits/stdc++.h>
#include<unordered_map>
#include<unordered_set>
#include<algorithm>
using namespace std;

#define mp make_pair
#define pb push_back
#define pii pair<int,int>
#define fi first
#define se second 
const int maxn = 2e5 + 50;
vector<vector<int>> adj(maxn);
vector<int>vis(maxn), s(maxn);
int tot;
void run(int u) {
	priority_queue<pii, vector<pii>, greater<pii>> pq;
	pq.push(mp(0, u));
	while (pq.size()) {
		pii uu = pq.top(); pq.pop();
		if (vis[uu.se] || uu.fi > tot) continue; 
		vis[uu.se] = 1; tot += uu.fi;
		for (auto& v : adj[uu.se]) {
			pq.push(mp(s[v], v));
		}
	}
}
signed main() {
	ios_base::sync_with_stdio(0); cin.tie(0);
	int n, m; cin >> n >> m;
	for (int i = 0; i < n; i++) cin >> s[i];
	for (int i = 0; i < m; i++) {
		int u, v; cin >> u >> v;
		u--; v--;
		adj[u].pb(v); adj[v].pb(u);
	}
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < n; j++) vis[j] = 0;
		tot = s[i]; run(i);
		int ok = 1; for (int j = 0; j < n; j++) ok &= vis[j];
		cout << ok;
	}
}
# Verdict Execution time Memory Grader output
1 Correct 4 ms 6484 KB Output is correct
2 Correct 4 ms 6608 KB Output is correct
3 Correct 3 ms 6484 KB Output is correct
4 Incorrect 8 ms 6608 KB Output isn't correct
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 4 ms 6484 KB Output is correct
2 Correct 4 ms 6484 KB Output is correct
3 Execution timed out 1081 ms 17384 KB Time limit exceeded
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 3 ms 6484 KB Output is correct
2 Execution timed out 1070 ms 17220 KB Time limit exceeded
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 3 ms 6484 KB Output is correct
2 Execution timed out 1081 ms 17292 KB Time limit exceeded
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 4 ms 6484 KB Output is correct
2 Correct 4 ms 6608 KB Output is correct
3 Correct 3 ms 6484 KB Output is correct
4 Incorrect 8 ms 6608 KB Output isn't correct
5 Halted 0 ms 0 KB -