Submission #723130

#TimeUsernameProblemLanguageResultExecution timeMemory
723130rshohruhStranded Far From Home (BOI22_island)C++14
10 / 100
1084 ms15760 KiB
#include <bits/stdc++.h> using namespace std; #define int long long signed main() { int n, m; cin >> n >> m; vector<int> s(n+1); for (int i = 1; i <= n; ++i) cin >> s[i]; vector<vector<int>> ed(n+1); for (int i = 0; i < m; ++i){ int a, b; cin >> a >> b; ed[a].push_back(b); ed[b].push_back(a); } string res; for (int i = 1; i <= n; ++i){ int cursz = s[i]; set<pair<int, int>> st; vector<bool> visited(n+1); visited[i] = true; for (auto to : ed[i]) st.insert({s[to], to}); bool flag = true; while (!st.empty()){ auto it = st.begin(); if (it->first > cursz) { flag = false; break; } cursz += it->first; visited[it->second] = true; for (auto to : ed[it->second]) { if (visited[to]) continue; st.insert({s[to], to}); }; st.erase(it); } if (flag) res += '1'; else res += '0'; } cout << res << "\n"; return 0; }
#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...