Submission #723026

#TimeUsernameProblemLanguageResultExecution timeMemory
723026Erkinoff_MohammedStranded Far From Home (BOI22_island)C++14
10 / 100
359 ms440 KiB
#include "bits/stdc++.h" using namespace std; #define INF 2000000000 #define INFLL 3000000000000000000LL #define ll long long int main() { cin.tie(0)->sync_with_stdio(0); int n,m; cin>>n>>m; if(n<=2000&&m<=2000){ long long siz[n+1]; for(int i=1;i<=n;i++)cin>>siz[i]; vector<int>adj[n+1]; for(int i=0;i<m;i++){ int a,b; cin>>a>>b; adj[a].push_back(b); adj[b].push_back(a); } for(int i=1;i<=n;i++){ bool vis[n+1]; for(int i=0;i<=n;i++)vis[i]=0; priority_queue<pair<int,int>>q; long long cur=siz[i]; bool b=1; q.push({0,i}); while(!q.empty()){ auto u=q.top();q.pop(); int j=u.second; int si=-u.first; if(si>cur){ b=0; break; } vis[j]=1; cur+=si; for(int v:adj[j]){ if(!vis[v])q.push({-siz[v],v}); } } cout<<b; } } }
#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...