#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> ii;
const int MAX_N=2e5+10;
vector<vi> G;
int ha[MAX_N];
bool vis[MAX_N];
int n,m;
void bfs(int u){
for(int i=0;i<n;i++) vis[i]=0;
priority_queue<ii, vector<ii>, greater<ii> > q;
vis[u]=1; q.push(ii(0,u));
ll co=0;
while(!q.empty()){
int x=q.top().first; q.pop();
co+=ha[x];
for(auto &v:G[x]){
if(co>=ha[v] && !vis[v]){
q.push(ii(ha[v],v));
vis[v]=1;
}
}
}
}
int main(){
cin>>n>>m;
G.resize(n+1);
for(int i=0;i<n;i++) cin>>ha[i];
for(int i=0;i<m;i++){
int a,b; cin>>a>>b;
a--; b--;
G[a].push_back(b);
G[b].push_back(a);
}
string ans="";
for(int i=0;i<n;i++){
bfs(i);
bool all=1;
for(int j=0;j<n;j++) all&=vis[j];
if(all) ans+='1';
else ans+='0';
}
cout<<ans<<endl;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
212 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Runtime error |
242 ms |
24624 KB |
Execution killed with signal 11 |
4 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Execution timed out |
1083 ms |
12224 KB |
Time limit exceeded |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Execution timed out |
1095 ms |
12232 KB |
Time limit exceeded |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
212 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |