#include<iostream>
#include<stack>
#include<map>
#include<vector>
#include<string>
#include<unordered_map>
#include <queue>
#include<cstring>
#include<limits.h>
#include<cmath>
#include<set>
#include<algorithm>
#include<bitset>
#include <iomanip>
#include <cstdio>
#include <cstdlib>
#include <cstring>
using namespace std;
#define ll long long
#define f first
#define endl "\n"
#define s second
#define pii pair<int,int>
#define ppii pair<int,pii>
#define vi vector<int>
#define pb push_back
//#define p push
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define F(n) for(int i=0;i<n;i++)
#define lb lower_bound
#define ub upper_bound
#define fastio ios::sync_with_stdio(false);cin.tie(NULL);
using namespace std;
#pragma GCC optimize ("03,unroll-lopps")
#pragma GCC target("avx2")
#define int long long
const int mxn=2e5,inf=1e9;
vector<ppii>e;
int val[mxn+10],n,m,pa[mxn+10],sum[mxn+10];
bool ans[mxn+10];
int find(int u){return ((pa[u]==u)?u:pa[u]=find(pa[u]));}
void merg(int u,int v){
int a=find(u),b=find(v);
if(a==b)return;
if(sum[b]<val[u])ans[b]=true;
else pa[a]=b,ans[b]|=ans[a],sum[b]+=sum[a];
}
int32_t main(){
fastio
cin>>n>>m;
for(int i=1;i<=n;i++)cin>>val[i],sum[i]=val[i],pa[i]=i;
for(int i=0;i<m;i++){
int a,b;cin>>a>>b;
if(val[a]<val[b])swap(a,b);
e.pb({val[a],{a,b}});
}
sort(all(e));
for(auto i:e)merg(i.s.f,i.s.s);
for(int i=1;i<=n;i++)cout<<(!ans[find(i)]);
}
Compilation message
island.cpp:35:40: warning: bad option '-funroll-lopps' to pragma 'optimize' [-Wpragmas]
35 | #pragma GCC optimize ("03,unroll-lopps")
| ^
island.cpp:36:26: warning: bad option '-funroll-lopps' to attribute 'optimize' [-Wattributes]
36 | #pragma GCC target("avx2")
| ^
island.cpp:36:26: warning: bad option '-funroll-lopps' to attribute 'optimize' [-Wattributes]
island.cpp:36:26: warning: bad option '-funroll-lopps' to attribute 'optimize' [-Wattributes]
island.cpp:36:26: warning: bad option '-funroll-lopps' to attribute 'optimize' [-Wattributes]
island.cpp:36:26: warning: bad option '-funroll-lopps' to attribute 'optimize' [-Wattributes]
island.cpp:36:26: warning: bad option '-funroll-lopps' to attribute 'optimize' [-Wattributes]
island.cpp:36:26: warning: bad option '-funroll-lopps' to attribute 'optimize' [-Wattributes]
island.cpp:36:26: warning: bad option '-funroll-lopps' to attribute 'optimize' [-Wattributes]
island.cpp:36:26: warning: bad option '-funroll-lopps' to attribute 'optimize' [-Wattributes]
island.cpp:36:26: warning: bad option '-funroll-lopps' to attribute 'optimize' [-Wattributes]
island.cpp:36:26: warning: bad option '-funroll-lopps' to attribute 'optimize' [-Wattributes]
island.cpp:36:26: warning: bad option '-funroll-lopps' to attribute 'optimize' [-Wattributes]
island.cpp:36:26: warning: bad option '-funroll-lopps' to attribute 'optimize' [-Wattributes]
island.cpp:36:26: warning: bad option '-funroll-lopps' to attribute 'optimize' [-Wattributes]
island.cpp:36:26: warning: bad option '-funroll-lopps' to attribute 'optimize' [-Wattributes]
island.cpp:36:26: warning: bad option '-funroll-lopps' to attribute 'optimize' [-Wattributes]
island.cpp:36:26: warning: bad option '-funroll-lopps' to attribute 'optimize' [-Wattributes]
island.cpp:36:26: warning: bad option '-funroll-lopps' to attribute 'optimize' [-Wattributes]
island.cpp:36:26: warning: bad option '-funroll-lopps' to attribute 'optimize' [-Wattributes]
island.cpp:36:26: warning: bad option '-funroll-lopps' to attribute 'optimize' [-Wattributes]
island.cpp:36:26: warning: bad option '-funroll-lopps' to attribute 'optimize' [-Wattributes]
island.cpp:36:26: warning: bad option '-funroll-lopps' to attribute 'optimize' [-Wattributes]
island.cpp:36:26: warning: bad option '-funroll-lopps' to attribute 'optimize' [-Wattributes]
island.cpp:36:26: warning: bad option '-funroll-lopps' to attribute 'optimize' [-Wattributes]
island.cpp:36:26: warning: bad option '-funroll-lopps' to attribute 'optimize' [-Wattributes]
island.cpp:36:26: warning: bad option '-funroll-lopps' to attribute 'optimize' [-Wattributes]
island.cpp:36:26: warning: bad option '-funroll-lopps' to attribute 'optimize' [-Wattributes]
island.cpp:36:26: warning: bad option '-funroll-lopps' to attribute 'optimize' [-Wattributes]
island.cpp:36:26: warning: bad option '-funroll-lopps' to attribute 'optimize' [-Wattributes]
island.cpp:36:26: warning: bad option '-funroll-lopps' to attribute 'optimize' [-Wattributes]
island.cpp:36:26: warning: bad option '-funroll-lopps' to attribute 'optimize' [-Wattributes]
island.cpp:36:26: warning: bad option '-funroll-lopps' to attribute 'optimize' [-Wattributes]
island.cpp:36:26: warning: bad option '-funroll-lopps' to attribute 'optimize' [-Wattributes]
island.cpp:36:26: warning: bad option '-funroll-lopps' to attribute 'optimize' [-Wattributes]
island.cpp:36:26: warning: bad option '-funroll-lopps' to attribute 'optimize' [-Wattributes]
island.cpp:36:26: warning: bad option '-funroll-lopps' to attribute 'optimize' [-Wattributes]
island.cpp:36:26: warning: bad option '-funroll-lopps' to attribute 'optimize' [-Wattributes]
island.cpp:36:26: warning: bad option '-funroll-lopps' to attribute 'optimize' [-Wattributes]
island.cpp:36:26: warning: bad option '-funroll-lopps' to attribute 'optimize' [-Wattributes]
island.cpp:36:26: warning: bad option '-funroll-lopps' to attribute 'optimize' [-Wattributes]
island.cpp:36:26: warning: bad option '-funroll-lopps' to attribute 'optimize' [-Wattributes]
island.cpp:36:26: warning: bad option '-funroll-lopps' to attribute 'optimize' [-Wattributes]
island.cpp:36:26: warning: bad option '-funroll-lopps' to attribute 'optimize' [-Wattributes]
island.cpp:36:26: warning: bad option '-funroll-lopps' to attribute 'optimize' [-Wattributes]
island.cpp:36:26: warning: bad option '-funroll-lopps' to attribute 'optimize' [-Wattributes]
island.cpp:36:26: warning: bad option '-funroll-lopps' to attribute 'optimize' [-Wattributes]
island.cpp:36:26: warning: bad option '-funroll-lopps' to attribute 'optimize' [-Wattributes]
island.cpp:36:26: warning: bad option '-funroll-lopps' to attribute 'optimize' [-Wattributes]
island.cpp:36:26: warning: bad option '-funroll-lopps' to attribute 'optimize' [-Wattributes]
island.cpp:36:26: warning: bad option '-funroll-lopps' to attribute 'optimize' [-Wattributes]
island.cpp:36:26: warning: bad option '-funroll-lopps' to attribute 'optimize' [-Wattributes]
island.cpp:36:26: warning: bad option '-funroll-lopps' to attribute 'optimize' [-Wattributes]
island.cpp:36:26: warning: bad option '-funroll-lopps' to attribute 'optimize' [-Wattributes]
island.cpp:36:26: warning: bad option '-funroll-lopps' to attribute 'optimize' [-Wattributes]
island.cpp:36:26: warning: bad option '-funroll-lopps' to attribute 'optimize' [-Wattributes]
island.cpp:36:26: warning: bad option '-funroll-lopps' to attribute 'optimize' [-Wattributes]
island.cpp:36:26: warning: bad option '-funroll-lopps' to attribute 'optimize' [-Wattributes]
island.cpp:36:26: warning: bad option '-funroll-lopps' to attribute 'optimize' [-Wattributes]
island.cpp:36:26: warning: bad option '-funroll-lopps' to attribute 'optimize' [-Wattributes]
island.cpp:36:26: warning: bad option '-funroll-lopps' to attribute 'optimize' [-Wattributes]
island.cpp:36:26: warning: bad option '-funroll-lopps' to attribute 'optimize' [-Wattributes]
island.cpp:36:26: warning: bad option '-funroll-lopps' to attribute 'optimize' [-Wattributes]
island.cpp:36:26: warning: bad option '-funroll-lopps' to attribute 'optimize' [-Wattributes]
island.cpp:36:26: warning: bad option '-funroll-lopps' to attribute 'optimize' [-Wattributes]
island.cpp:36:26: warning: bad option '-funroll-lopps' to attribute 'optimize' [-Wattributes]
island.cpp:36:26: warning: bad option '-funroll-lopps' to attribute 'optimize' [-Wattributes]
island.cpp:36:26: warning: bad option '-funroll-lopps' to attribute 'optimize' [-Wattributes]
island.cpp:36:26: warning: bad option '-funroll-lopps' to attribute 'optimize' [-Wattributes]
island.cpp:36:26: warning: bad option '-funroll-lopps' to attribute 'optimize' [-Wattributes]
island.cpp:36:26: warning: bad option '-funroll-lopps' to attribute 'optimize' [-Wattributes]
island.cpp:36:26: warning: bad option '-funroll-lopps' to attribute 'optimize' [-Wattributes]
island.cpp:36:26: warning: bad option '-funroll-lopps' to attribute 'optimize' [-Wattributes]
island.cpp:36:26: warning: bad option '-funroll-lopps' to attribute 'optimize' [-Wattributes]
island.cpp:36:26: warning: bad option '-funroll-lopps' to attribute 'optimize' [-Wattributes]
island.cpp:36:26: warning: bad option '-funroll-lopps' to attribute 'optimize' [-Wattributes]
island.cpp:36:26: warning: bad option '-funroll-lopps' to attribute 'optimize' [-Wattributes]
island.cpp:36:26: warning: bad option '-funroll-lopps' to attribute 'optimize' [-Wattributes]
island.cpp:36:26: warning: bad option '-funroll-lopps' to attribute 'optimize' [-Wattributes]
island.cpp:36:26: warning: bad option '-funroll-lopps' to attribute 'optimize' [-Wattributes]
island.cpp:36:26: warning: bad option '-funroll-lopps' to attribute 'optimize' [-Wattributes]
island.cpp:36:26: warning: bad option '-funroll-lopps' to attribute 'optimize' [-Wattributes]
island.cpp:36:26: warning: bad option '-funroll-lopps' to attribute 'optimize' [-Wattributes]
island.cpp:36:26: warning: bad option '-funroll-lopps' to attribute 'optimize' [-Wattributes]
island.cpp:36:26: warning: bad option '-funroll-lopps' to attribute 'optimize' [-Wattributes]
island.cpp:36:26: warning: bad option '-funroll-lopps' to attribute 'optimize' [-Wattributes]
island.cpp:36:26: warning: bad option '-funroll-lopps' to attribute 'optimize' [-Wattributes]
island.cpp:36:26: warning: bad option '-funroll-lopps' to attribute 'optimize' [-Wattributes]
island.cpp:36:26: warning: bad option '-funroll-lopps' to attribute 'optimize' [-Wattributes]
island.cpp:36:26: warning: bad option '-funroll-lopps' to attribute 'optimize' [-Wattributes]
island.cpp:36:26: warning: bad option '-funroll-lopps' to attribute 'optimize' [-Wattributes]
island.cpp:36:26: warning: bad option '-funroll-lopps' to attribute 'optimize' [-Wattributes]
island.cpp:36:26: warning: bad option '-funroll-lopps' to attribute 'optimize' [-Wattributes]
island.cpp:36:26: warning: bad option '-funroll-lopps' to attribute 'optimize' [-Wattributes]
island.cpp:36:26: warning: bad option '-funroll-lopps' to attribute 'optimize' [-Wattributes]
island.cpp:36:26: warning: bad option '-funroll-lopps' to attribute 'optimize' [-Wattributes]
island.cpp:36:26: warning: bad option '-funroll-lopps' to attribute 'optimize' [-Wattributes]
island.cpp:36:26: warning: bad option '-funroll-lopps' to attribute 'optimize' [-Wattributes]
island.cpp:36:26: warning: bad option '-funroll-lopps' to attribute 'optimize' [-Wattributes]
island.cpp:36:26: warning: bad option '-funroll-lopps' to attribute 'optimize' [-Wattributes]
island.cpp:36:26: warning: bad option '-funroll-lopps' to attribute 'optimize' [-Wattributes]
island.cpp:36:26: warning: bad option '-funroll-lopps' to attribute 'optimize' [-Wattributes]
island.cpp:36:26: warning: bad option '-funroll-lopps' to attribute 'optimize' [-Wattributes]
island.cpp:36:26: warning: bad option '-funroll-lopps' to attribute 'optimize' [-Wattributes]
island.cpp:36:26: warning: bad option '-funroll-lopps' to attribute 'optimize' [-Wattributes]
island.cpp:36:26: warning: bad option '-funroll-lopps' to attribute 'optimize' [-Wattributes]
island.cpp:36:26: warning: bad option '-funroll-lopps' to attribute 'optimize' [-Wattributes]
island.cpp:36:26: warning: bad option '-funroll-lopps' to attribute 'optimize' [-Wattributes]
island.cpp:36:26: warning: bad option '-funroll-lopps' to attribute 'optimize' [-Wattributes]
island.cpp:36:26: warning: bad option '-funroll-lopps' to attribute 'optimize' [-Wattributes]
island.cpp:36:26: warning: bad option '-funroll-lopps' to attribute 'optimize' [-Wattributes]
island.cpp:36:26: warning: bad option '-funroll-lopps' to attribute 'optimize' [-Wattributes]
island.cpp:36:26: warning: bad option '-funroll-lopps' to attribute 'optimize' [-Wattributes]
island.cpp:36:26: warning: bad option '-funroll-lopps' to attribute 'optimize' [-Wattributes]
island.cpp:36:26: warning: bad option '-funroll-lopps' to attribute 'optimize' [-Wattributes]
island.cpp:36:26: warning: bad option '-funroll-lopps' to attribute 'optimize' [-Wattributes]
island.cpp:36:26: warning: bad option '-funroll-lopps' to attribute 'optimize' [-Wattributes]
island.cpp:36:26: warning: bad option '-funroll-lopps' to attribute 'optimize' [-Wattributes]
island.cpp:36:26: warning: bad option '-funroll-lopps' to attribute 'optimize' [-Wattributes]
island.cpp:36:26: warning: bad option '-funroll-lopps' to attribute 'optimize' [-Wattributes]
island.cpp:36:26: warning: bad option '-funroll-lopps' to attribute 'optimize' [-Wattributes]
island.cpp:36:26: warning: bad option '-funroll-lopps' to attribute 'optimize' [-Wattributes]
island.cpp:36:26: warning: bad option '-funroll-lopps' to attribute 'optimize' [-Wattributes]
island.cpp:36:26: warning: bad option '-funroll-lopps' to attribute 'optimize' [-Wattributes]
island.cpp:36:26: warning: bad option '-funroll-lopps' to attribute 'optimize' [-Wattributes]
island.cpp:36:26: warning: bad option '-funroll-lopps' to attribute 'optimize' [-Wattributes]
island.cpp:36:26: warning: bad option '-funroll-lopps' to attribute 'optimize' [-Wattributes]
island.cpp:36:26: warning: bad option '-funroll-lopps' to attribute 'optimize' [-Wattributes]
island.cpp:36:26: warning: bad option '-funroll-lopps' to attribute 'optimize' [-Wattributes]
island.cpp:36:26: warning: bad option '-funroll-lopps' to attribute 'optimize' [-Wattributes]
island.cpp:36:26: warning: bad option '-funroll-lopps' to attribute 'optimize' [-Wattributes]
island.cpp:36:26: warning: bad option '-funroll-lopps' to attribute 'optimize' [-Wattributes]
island.cpp:36:26: warning: bad option '-funroll-lopps' to attribute 'optimize' [-Wattributes]
island.cpp:36:26: warning: bad option '-funroll-lopps' to attribute 'optimize' [-Wattributes]
island.cpp:36:26: warning: bad option '-funroll-lopps' to attribute 'optimize' [-Wattributes]
island.cpp:36:26: warning: bad option '-funroll-lopps' to attribute 'optimize' [-Wattributes]
island.cpp:36:26: warning: bad option '-funroll-lopps' to attribute 'optimize' [-Wattributes]
island.cpp:36:26: warning: bad option '-funroll-lopps' to attribute 'optimize' [-Wattributes]
island.cpp:36:26: warning: bad option '-funroll-lopps' to attribute 'optimize' [-Wattributes]
island.cpp:36:26: warning: bad option '-funroll-lopps' to attribute 'optimize' [-Wattributes]
island.cpp:36:26: warning: bad option '-funroll-lopps' to attribute 'optimize' [-Wattributes]
island.cpp:36:26: warning: bad option '-funroll-lopps' to attribute 'optimize' [-Wattributes]
island.cpp:36:26: warning: bad option '-funroll-lopps' to attribute 'optimize' [-Wattributes]
island.cpp:36:26: warning: bad option '-funroll-lopps' to attribute 'optimize' [-Wattributes]
island.cpp:36:26: warning: bad option '-funroll-lopps' to attribute 'optimize' [-Wattributes]
island.cpp:36:26: warning: bad option '-funroll-lopps' to attribute 'optimize' [-Wattributes]
island.cpp:36:26: warning: bad option '-funroll-lopps' to attribute 'optimize' [-Wattributes]
island.cpp:36:26: warning: bad option '-funroll-lopps' to attribute 'optimize' [-Wattributes]
island.cpp:36:26: warning: bad option '-funroll-lopps' to attribute 'optimize' [-Wattributes]
island.cpp:36:26: warning: bad option '-funroll-lopps' to attribute 'optimize' [-Wattributes]
island.cpp:36:26: warning: bad option '-funroll-lopps' to attribute 'optimize' [-Wattributes]
island.cpp:36:26: warning: bad option '-funroll-lopps' to attribute 'optimize' [-Wattributes]
island.cpp:36:26: warning: bad option '-funroll-lopps' to attribute 'optimize' [-Wattributes]
island.cpp:36:26: warning: bad option '-funroll-lopps' to attribute 'optimize' [-Wattributes]
island.cpp:36:26: warning: bad option '-funroll-lopps' to attribute 'optimize' [-Wattributes]
island.cpp:36:26: warning: bad option '-funroll-lopps' to attribute 'optimize' [-Wattributes]
island.cpp:36:26: warning: bad option '-funroll-lopps' to attribute 'optimize' [-Wattributes]
island.cpp:36:26: warning: bad option '-funroll-lopps' to attribute 'optimize' [-Wattributes]
island.cpp:36:26: warning: bad option '-funroll-lopps' to attribute 'optimize' [-Wattributes]
island.cpp:36:26: warning: bad option '-funroll-lopps' to attribute 'optimize' [-Wattributes
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
4448 KB |
Output is correct |
2 |
Correct |
1 ms |
4444 KB |
Output is correct |
3 |
Correct |
1 ms |
4448 KB |
Output is correct |
4 |
Incorrect |
2 ms |
4704 KB |
Output isn't correct |
5 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
4452 KB |
Output is correct |
2 |
Correct |
1 ms |
4448 KB |
Output is correct |
3 |
Incorrect |
84 ms |
16612 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
4444 KB |
Output is correct |
2 |
Incorrect |
68 ms |
17056 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
4440 KB |
Output is correct |
2 |
Incorrect |
92 ms |
15384 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
4448 KB |
Output is correct |
2 |
Correct |
1 ms |
4444 KB |
Output is correct |
3 |
Correct |
1 ms |
4448 KB |
Output is correct |
4 |
Incorrect |
2 ms |
4704 KB |
Output isn't correct |
5 |
Halted |
0 ms |
0 KB |
- |