#include<bits/stdc++.h>
#define MAXN 200007
using namespace std;
int n,m,a,b,curr;
long long s[MAXN];
vector<int> v[MAXN];
int p[MAXN],dsu[MAXN];
long long sz[MAXN];
vector<int> can[MAXN];
bool in[MAXN],notok[MAXN];
bool cmp(int x,int y){
return s[x]<s[y];
}
int root(int x){
if(dsu[x]==x)return dsu[x];
dsu[x]=root(dsu[x]);
return dsu[x];
}
int main(){
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
cin>>n>>m;
for(int i=1;i<=n;i++){
cin>>s[i];
p[i]=i; dsu[i]=i;
sz[i]=s[i]; can[i]={i};
}
sort(p+1,p+n+1,cmp);
for(int i=1;i<=m;i++){
cin>>a>>b;
v[a].push_back(b);
v[b].push_back(a);
}
for(int i=1;i<=n;i++){
curr=p[i];
for(int f:v[curr]){
if(!in[f])continue;
if(sz[root(f)]<s[curr]){
for(int k:can[root(f)])notok[k]=true;
can[root(f)].clear();
}
if(can[root(f)].size()<can[root(curr)].size()){
for(int k:can[root(f)])can[root(curr)].push_back(k);
sz[root(curr)]+=sz[root(f)];
dsu[root(f)]=root(curr);
}else{
for(int k:can[root(curr)])can[root(f)].push_back(k);
sz[root(f)]+=sz[root(curr)];
dsu[root(curr)]=root(f);
}
}
in[curr]=true;
}
for(int i=1;i<=n;i++){
if(notok[i])cout<<0;
else cout<<1;
}
cout<<"\n";
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
5 ms |
9684 KB |
Output is correct |
2 |
Correct |
5 ms |
9684 KB |
Output is correct |
3 |
Correct |
5 ms |
9720 KB |
Output is correct |
4 |
Runtime error |
17 ms |
20436 KB |
Execution killed with signal 11 |
5 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
5 ms |
9684 KB |
Output is correct |
2 |
Correct |
5 ms |
9684 KB |
Output is correct |
3 |
Correct |
140 ms |
28540 KB |
Output is correct |
4 |
Correct |
153 ms |
31448 KB |
Output is correct |
5 |
Correct |
169 ms |
29776 KB |
Output is correct |
6 |
Correct |
181 ms |
30476 KB |
Output is correct |
7 |
Correct |
181 ms |
30320 KB |
Output is correct |
8 |
Correct |
169 ms |
29400 KB |
Output is correct |
9 |
Correct |
155 ms |
31516 KB |
Output is correct |
10 |
Correct |
137 ms |
28272 KB |
Output is correct |
11 |
Correct |
116 ms |
29424 KB |
Output is correct |
12 |
Correct |
170 ms |
29144 KB |
Output is correct |
13 |
Correct |
149 ms |
31876 KB |
Output is correct |
14 |
Correct |
157 ms |
31560 KB |
Output is correct |
15 |
Correct |
141 ms |
28344 KB |
Output is correct |
16 |
Correct |
96 ms |
28068 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
5 ms |
9684 KB |
Output is correct |
2 |
Correct |
216 ms |
31036 KB |
Output is correct |
3 |
Correct |
227 ms |
31160 KB |
Output is correct |
4 |
Correct |
148 ms |
31768 KB |
Output is correct |
5 |
Correct |
149 ms |
31784 KB |
Output is correct |
6 |
Correct |
216 ms |
31180 KB |
Output is correct |
7 |
Correct |
168 ms |
28328 KB |
Output is correct |
8 |
Correct |
163 ms |
28200 KB |
Output is correct |
9 |
Correct |
94 ms |
28048 KB |
Output is correct |
10 |
Correct |
145 ms |
29384 KB |
Output is correct |
11 |
Correct |
169 ms |
30748 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
5 ms |
9684 KB |
Output is correct |
2 |
Runtime error |
200 ms |
57488 KB |
Execution killed with signal 11 |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
5 ms |
9684 KB |
Output is correct |
2 |
Correct |
5 ms |
9684 KB |
Output is correct |
3 |
Correct |
5 ms |
9720 KB |
Output is correct |
4 |
Runtime error |
17 ms |
20436 KB |
Execution killed with signal 11 |
5 |
Halted |
0 ms |
0 KB |
- |