Submission #1098911

#TimeUsernameProblemLanguageResultExecution timeMemory
1098911crafticatStranded Far From Home (BOI22_island)C++17
0 / 100
1089 ms17444 KiB
#include <bits/stdc++.h> #include <utility> using namespace std; #define F0R(i, n) for (int i= 0; i < n;i++) template<typename T> using V = vector<T>; using vi = V<int>; using vvi = V<vi>; #define pb push_back using pi = pair<int, int>; #define all(x) begin(x), end(x) #define f first #define s second vvi g; bool pos(int x, vi sum) { priority_queue<pi,V<pi>, greater<>> nodes; nodes.push({sum[x], x}); int gs = 0; V<bool> vis(sum.size()); while (!nodes.empty()) { auto [nodeS, a] = nodes.top(); nodes.pop(); if (vis[a]) continue; vis[a] = true; if (nodeS > gs && gs != 0) return false; gs += nodeS; for (auto child : g[x]) { if (vis[child]) continue; nodes.emplace(sum[child], child); } } return true; } int main() { int n, m; cin >> n >> m; vi init(n + 1); F0R(i, n) cin >> init[i + 1]; g.resize(n + 1); F0R(i, m) { int a, b; cin >> a >> b; g[a].pb(b); g[b].pb(a); } F0R(i, n) cout << pos(i + 1, init); }
#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...