제출 #574130

#제출 시각아이디문제언어결과실행 시간메모리
574130eecsStranded Far From Home (BOI22_island)C++17
10 / 100
1086 ms14144 KiB
#include <bits/stdc++.h> using namespace std; const int maxn = 200010; int n, m, a[maxn], vis[maxn]; vector<int> G[maxn]; int main() { ios::sync_with_stdio(0), cin.tie(0); cin >> n >> m; for (int i = 1; i <= n; i++) { cin >> a[i]; } while (m--) { int u, v; cin >> u >> v; G[u].push_back(v), G[v].push_back(u); } for (int i = 1; i <= n; i++) { set<pair<int, int>> cand; long long s = 0; cand.emplace(0, i); while (!cand.empty() && cand.begin()->first <= s) { int j = cand.begin()->second; s += a[j], vis[j] = i; cand.erase(cand.begin()); for (int k : G[j]) { if (i ^ vis[k]) cand.emplace(a[k], k); } } cout << (cand.empty() ? '1' : '0'); } 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...