Submission #578127

#TimeUsernameProblemLanguageResultExecution timeMemory
5781278e7Stranded Far From Home (BOI22_island)C++17
10 / 100
1087 ms13624 KiB
//Challenge: Accepted #include <bits/stdc++.h> using namespace std; #ifdef zisk void debug(){cout << endl;} template<class T, class ... U> void debug(T a, U ... b){cout << a << " ", debug(b...); } template<class T> void pary(T l, T r) { while (l != r) cout << *l << " ", l++; cout << endl; } #else #define debug(...) 0 #define pary(...) 0 #endif #define ll long long #define maxn 200005 #define maxc 31 #define pii pair<int, int> #define ff first #define ss second #define io ios_base::sync_with_stdio(0);cin.tie(0); const ll inf = 1LL<<60; vector<int> adj[maxn]; ll w[maxn]; int lev[maxn]; bool vis[maxn]; int main() { io int n, m; cin >> n >> m; ll tot = 0; for (int i = 1;i <= n;i++) cin >> w[i], tot += w[i]; for (int i = 0;i < m;i++) { int u, v; cin >> u >> v; adj[u].push_back(v); adj[v].push_back(u); } string ans; for (int i = 1;i <= n;i++) { for (int j = 1;j <= n;j++) vis[j] = 0; priority_queue<pii, vector<pii>, greater<pii> > pq; pq.push({w[i], i}); ll sum = 0; bool poss = 1; while (pq.size()) { auto [val, cur] = pq.top();pq.pop(); if (sum != 0 && sum < val) { poss = 0; break; } sum += val; vis[cur] = 1; for (int v:adj[cur]) { if (!vis[v]) { vis[v] = 1; pq.push({w[v], v}); } } } if (poss) ans += '1'; else ans += '0'; } cout << ans << "\n"; } /* 6 7 8 5 4 4 6 20 1 2 1 3 1 4 2 3 2 4 1 5 5 6 */
#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...