Submission #919080

#TimeUsernameProblemLanguageResultExecution timeMemory
919080IsamStranded Far From Home (BOI22_island)C++17
Compilation error
0 ms0 KiB
#include<iostream> #include<vector> #include<algorithm> using namespace std; #define int long long const int sz=200005; int n, m, sizel[sz], fa[sz]; int folk[sz], sm[sz]; bool ans[sz]; inline void init(){ for(int i=1; i<=n; ++i) sizel[i]=1, fa[i]=i, ans[i]=true; return; } int find_set(int &v){ if(fa[v] == v) return v; if(!ans[fa[v]]) ans[v]=0; return fa[v]=find_set(fa[v]); } //b->a bool Union(int a, int b){ a = find_set(a); b = find_set(b); if(a ^ b){ if(folk[a]<folk[b]) swap(a,b); if(folk[a]>sm[b]) ans[b]=0; fa[b]=a; sm[a]+=sm[b]; return true; } return false; } struct edge{ int a, b; int maxf; }; bool cmp(edge e1, edge e2){ return e1.maxf<e2.maxf; } vector<edge> e; int a, b, maxf; inline void Solution(){ cin>>n>>m; init(); for(int i=1; i<=n; ++i){ cin>>folk[i]; sm[i]=folk[i]; } for(int i=1; i<=m; ++i){ cin>>a>>b; e.emplace_back((edge){a,b,max(folk[a], folk[b])}); } sort(e.begin(), e.end(), cmp); for(int i=0; i<m; ++i){ Union(e[i].a, e[i].b); } for(int i=1; i<=n; ++i) cout<<ans[i]; return; } int main(){ ios_base::sync_with_stdio(false); Solution(); return 0; }

Compilation message (stderr)

cc1plus: error: '::main' must return 'int'