Submission #830313

#TimeUsernameProblemLanguageResultExecution timeMemory
830313WarinchaiStranded Far From Home (BOI22_island)C++14
0 / 100
1083 ms14612 KiB
#include<bits/stdc++.h> using namespace std; long long ar[200005]; vector<int>v[200005]; int vis[200005]; int n,m; int check(int i){ for(int i=1;i<=n;i++){ vis[i]=0; } priority_queue<pair<long long,int>,vector<pair<long long,int> >,greater<pair<long long,int> > >pq; pq.push({ar[i],i}); vis[i]=1; long long power=0; int hv=0; while(!pq.empty()){ hv++; long long np=pq.top().first; int x=pq.top().second; //cout<<x<<" "<<power<<endl; pq.pop(); if(x==i||power>=np){ power+=np; for(int j=0;j<v[x].size();j++){ if(vis[v[x][j]]==1){ continue; } vis[v[x][j]]=1; pq.push({ar[v[x][j]],v[x][j]}); } }else{ break; } } if(hv==n){ return 1; }else{ return 0; } } int main(){ ios_base::sync_with_stdio(false); cin.tie(0); cin>>n>>m; for(int i=1;i<=n;i++){ cin>>ar[i]; } for(int i=1;i<=m;i++){ int a,b; cin>>a>>b; v[a].push_back(b); v[b].push_back(a); } for(int i=1;i<=n;i++){ cout<<check(i); } }

Compilation message (stderr)

island.cpp: In function 'int check(int)':
island.cpp:24:26: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   24 |             for(int j=0;j<v[x].size();j++){
      |                         ~^~~~~~~~~~~~
#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...