Submission #722882

#TimeUsernameProblemLanguageResultExecution timeMemory
722882MDSProStranded Far From Home (BOI22_island)C++17
0 / 100
511 ms17532 KiB
#include "bits/stdc++.h" using namespace std; int main(){ int n,m; cin >> n >> m; vector<int> 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<int,int>> st; st.insert({0,i}); vis[i] = i; int 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...