Submission #591155

#TimeUsernameProblemLanguageResultExecution timeMemory
591155tutisStranded Far From Home (BOI22_island)C++17
10 / 100
1092 ms13664 KiB
/*input 4 3 4 2 2 1 1 2 3 2 4 1 */ #include <bits/stdc++.h> using namespace std; using ll = long long; int main() { ios_base::sync_with_stdio(false); int N, M; cin >> N >> M; int S[N]; for (int i = 0; i < N; i++) cin >> S[i]; vector<int>adj[N]; while (M--) { int a, b; cin >> a >> b; a--; b--; adj[a].push_back(b); adj[b].push_back(a); } vector<bool>ret(N, false); for (int i = 0; i < N; i++) { vector<bool>vis(N, false); vis[i] = true; ll sum = S[i]; set<pair<int, int>>Q; for (int j : adj[i]) { vis[j] = true; Q.insert({S[j], j}); } int cnt = 1; while (!Q.empty()) { int i = Q.begin()->second; Q.erase(Q.begin()); if (S[i] <= sum) { sum += S[i]; cnt++; for (int j : adj[i]) { if (vis[j] == false) { vis[j] = true; Q.insert({S[j], j}); } } } else break; } if (cnt == N) ret[i] = true; } for (int i : ret) cout << i; cout << "\n"; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...