#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define PUT(a, b) freopen(a, "r", stdin); freopen(b, "w", stdout);
#define all(a) a.begin(), a.end()
#define answerNO {cout << "No" << endl; return;}
#define answerYES {cout << "Yes" << endl; return;}
using namespace std;
//#define int long long
#define ff first
#define ss second
#define pb push_back
#define replr(i, a, b) for (int i = int(a); i <= int(b); ++i)
#define reprl(i, a, b) for (int i = int(a); i >= int(b); --i)
#define rep(i, n) for (int i = 0; i < int(n); ++i)
#define mkp(a, b) make_pair(a, b)
typedef long long ll;
typedef long double ld;
typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<PII> VPI;
typedef pair<ll, ll> PLL;
typedef vector<ll> VL;
typedef vector<PLL> VPL;
template<class T> T setmax(T& a, T b) {if (a < b) return a = b; return a;}
template<class T> T setmin(T& a, T b) {if (a < b) return a; return a = b;}
using namespace __gnu_pbds;
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
ll mod = 1e9+7;
vector<vector<ll>> gp;
vector<ll> a;
vector<ll> dist;
vector<ll> ans;
vector<ll> par;
vector<ll> sbtr;
vector<ll> vis;
void sub(ll node, ll p = -1){
par[node] = p;
sbtr[node] = a[node];
for(auto v : gp[node]) if(v != p){
sub(v, node);
sbtr[node] += sbtr[v];
}
}
void dfs1(ll u, ll p = -1){
if(p != -1 && ans[p] == 0)ans[u] = 0;
for(auto v : gp[u]) if(v != p){
dfs1(v, u);
}
}
inline void solve(){
ll n, m; cin >> n >> m;
gp.resize(n);
a.resize(n);
vis.resize(n);
sbtr.resize(n);
dist.resize(n);
par.resize(n);
ans.resize(n, -1);
rep(i, n){
cin >> a[i];
}
rep(i, m){
ll u, v; cin >> u >> v;
--u, --v;
gp[u].pb(v);
gp[v].pb(u);
}
sub(0, -1);
replr(i, 1, n - 1){
if(a[par[i]] > sbtr[i]){
ans[i] = 0;
}
else{
ans[i] = 1;
}
}
ans[0] = 1;
dfs1(0, -1);
for(auto x : ans){
cout << x;
}
}
signed main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL), cout.tie(NULL);
//PUT(".in", ".out");
int t = 1;
//cin >> t;
while(t--){
solve();
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
351 ms |
524288 KB |
Execution killed with signal 9 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
114 ms |
31296 KB |
Output is correct |
4 |
Correct |
91 ms |
30036 KB |
Output is correct |
5 |
Correct |
126 ms |
25532 KB |
Output is correct |
6 |
Correct |
115 ms |
26192 KB |
Output is correct |
7 |
Correct |
112 ms |
26452 KB |
Output is correct |
8 |
Correct |
106 ms |
26448 KB |
Output is correct |
9 |
Correct |
103 ms |
27612 KB |
Output is correct |
10 |
Correct |
69 ms |
26052 KB |
Output is correct |
11 |
Correct |
69 ms |
25788 KB |
Output is correct |
12 |
Correct |
100 ms |
24916 KB |
Output is correct |
13 |
Correct |
107 ms |
36580 KB |
Output is correct |
14 |
Correct |
97 ms |
36432 KB |
Output is correct |
15 |
Correct |
104 ms |
37776 KB |
Output is correct |
16 |
Correct |
72 ms |
36732 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
344 KB |
Output is correct |
2 |
Incorrect |
104 ms |
33304 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Execution timed out |
1102 ms |
509672 KB |
Time limit exceeded |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
351 ms |
524288 KB |
Execution killed with signal 9 |
2 |
Halted |
0 ms |
0 KB |
- |