Submission #722883

#TimeUsernameProblemLanguageResultExecution timeMemory
722883MDSProStranded Far From Home (BOI22_island)C++17
10 / 100
1078 ms15500 KiB
#include "bits/stdc++.h" using namespace std; int main(){ int n,m; cin >> n >> m; vector<long long> a(n+1); for(int i = 1; i <= n; ++i) cin >> a[i]; vector<vector<int>> g(n+1); for(int i = 0; i < m; ++i){ int x,y; cin >> x >> y; g[x].emplace_back(y); g[y].emplace_back(x); } vector<int> vis(n+1,0); for(int i = 1; i <= n; ++i){ set<pair<long long,int>> st; st.insert({0,i}); vis[i] = i; long long cur = 0; while(!st.empty()){ auto [cnt,x] = *st.begin(); if(cnt > cur) break; st.erase(st.begin()); cur += a[x]; for(int z: g[x]){ if(vis[z] != i) { vis[z] = i; st.insert({a[z],z}); } } } if(st.empty()) cout << 1; else cout << 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...