#include "bits/stdc++.h"
using namespace std;
#define INF 2000000000
#define INFLL 3000000000000000000LL
#define ll long long
int main() {
cin.tie(0)->sync_with_stdio(0);
int n,m;
cin>>n>>m;
if(n<=2000&&m<=2000){
long long siz[n+1];
for(int i=1;i<=n;i++)cin>>siz[i];
vector<int>adj[n+1];
for(int i=0;i<m;i++){
int a,b;
cin>>a>>b;
adj[a].push_back(b);
adj[b].push_back(a);
}
for(int i=1;i<=n;i++){
bool vis[n+1];
for(int i=0;i<=n;i++)vis[i]=0;
priority_queue<pair<int,int>>q;
long long cur=siz[i];
bool b=1;
q.push({0,i});
while(!q.empty()){
auto u=q.top();q.pop();
int j=u.second;
int si=-u.first;
if(si>cur){
b=0;
break;
}
vis[j]=1;
cur+=si;
for(int v:adj[j]){
if(!vis[v])q.push({-siz[v],v});
}
}
cout<<b;
}
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
0 ms |
212 KB |
Output is correct |
4 |
Correct |
201 ms |
412 KB |
Output is correct |
5 |
Correct |
150 ms |
428 KB |
Output is correct |
6 |
Correct |
359 ms |
404 KB |
Output is correct |
7 |
Correct |
229 ms |
412 KB |
Output is correct |
8 |
Correct |
179 ms |
396 KB |
Output is correct |
9 |
Correct |
222 ms |
440 KB |
Output is correct |
10 |
Correct |
61 ms |
424 KB |
Output is correct |
11 |
Correct |
62 ms |
424 KB |
Output is correct |
12 |
Correct |
71 ms |
428 KB |
Output is correct |
13 |
Correct |
108 ms |
340 KB |
Output is correct |
14 |
Correct |
99 ms |
424 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Incorrect |
0 ms |
212 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Incorrect |
1 ms |
212 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Incorrect |
1 ms |
212 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
0 ms |
212 KB |
Output is correct |
4 |
Correct |
201 ms |
412 KB |
Output is correct |
5 |
Correct |
150 ms |
428 KB |
Output is correct |
6 |
Correct |
359 ms |
404 KB |
Output is correct |
7 |
Correct |
229 ms |
412 KB |
Output is correct |
8 |
Correct |
179 ms |
396 KB |
Output is correct |
9 |
Correct |
222 ms |
440 KB |
Output is correct |
10 |
Correct |
61 ms |
424 KB |
Output is correct |
11 |
Correct |
62 ms |
424 KB |
Output is correct |
12 |
Correct |
71 ms |
428 KB |
Output is correct |
13 |
Correct |
108 ms |
340 KB |
Output is correct |
14 |
Correct |
99 ms |
424 KB |
Output is correct |
15 |
Correct |
0 ms |
212 KB |
Output is correct |
16 |
Correct |
0 ms |
212 KB |
Output is correct |
17 |
Incorrect |
0 ms |
212 KB |
Output isn't correct |
18 |
Halted |
0 ms |
0 KB |
- |