Submission #581852

# Submission time Handle Problem Language Result Execution time Memory
581852 2022-06-23T07:22:39 Z temporary_juggernaut Stranded Far From Home (BOI22_island) C++14
Compilation error
0 ms 0 KB
#include<bits/stdc++.h>
#define fr first
#define sc second
using namespace std;
typedef long long ll;
typedef long double ld;
#define USING_ORDERED_SET 0
#if USING_ORDERED_SET
#include<bits/extc++.h>
using namespace __gnu_pbds;
template<class T>using ordered_set=tree<T,null_type,less<T>,rb_tree_tag,tree_order_statistics_node_update>;
#endif
template<class T>void umax(T &a,T b){if(a<b)a=b;}
template<class T>void umin(T &a,T b){if(b<a)a=b;}
#ifdef juggernaut
    #define printl(args...) printf(args)
#else
    #define printl(args...) 0
#endif
int a[200005];
int par[200005];
ll sum[200005];
vector<int>comp[200005];
int mx[200005];
pair<int,int>edge[200005];
int n,m;
int cash;
bool cmp(pair<int,int>l,pair<int,int>r){
	if(a[l.fr]==a[r.fr]){
		if(a[l.sc]==a[r.sc])return l<r;
		return return a[l.sc]<a[r.sc];;
	}
	return a[l.fr]<a[r.fr];
}
int fin(int v){return v==par[v]?v:par[v]=fin(par[v]);}
void unite(int a,int b){
	a=fin(a);
	b=fin(b);
	if(a==b)return;
	if(comp[a].size()<comp[b].size())swap(a,b);
	if(sum[a]<mx[b])comp[a].clear();
	if(sum[b]<mx[a])comp[b].clear();
	par[b]=a;
	umax(mx[a],mx[b]);
	sum[a]+=sum[b];
	cash=a;
	comp[a].insert(comp[a].end(),comp[b].begin(),comp[b].end());
	comp[b].clear();
}
int ans[200005];
int main(){
	scanf("%d%d",&n,&m);
	for(int i=1;i<=n;i++){
		scanf("%d",&a[i]);
		mx[i]=a[i];
		sum[i]=a[i];
		comp[i].push_back(i);
		par[i]=i;
	}
	for(int i=1;i<=m;i++){
		scanf("%d%d",&edge[i].fr,&edge[i].sc);
		if(a[edge[i].fr]<a[edge[i].sc])swap(edge[i].fr,edge[i].sc);
	}
	sort(edge+1,edge+1+m,cmp);
	for(int i=1;i<=m;i++)unite(edge[i].fr,edge[i].sc);
	for(int to:comp[cash])ans[to]=1;
	for(int i=1;i<=n;i++)printf("%d",ans[i]);
}

Compilation message

island.cpp: In function 'bool cmp(std::pair<int, int>, std::pair<int, int>)':
island.cpp:31:10: error: expected primary-expression before 'return'
   31 |   return return a[l.sc]<a[r.sc];;
      |          ^~~~~~
island.cpp:31:9: error: expected ';' before 'return'
   31 |   return return a[l.sc]<a[r.sc];;
      |         ^~~~~~~
      |         ;
island.cpp: In function 'int main()':
island.cpp:52:7: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   52 |  scanf("%d%d",&n,&m);
      |  ~~~~~^~~~~~~~~~~~~~
island.cpp:54:8: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   54 |   scanf("%d",&a[i]);
      |   ~~~~~^~~~~~~~~~~~
island.cpp:61:8: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   61 |   scanf("%d%d",&edge[i].fr,&edge[i].sc);
      |   ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~