This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#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 |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |