#include <bits/stdc++.h>
#include<unordered_map>
#include<unordered_set>
#include<algorithm>
using namespace std;
#define mp make_pair
#define pb push_back
#define pii pair<int,int>
#define fi first
#define se second
#define int long long
const int maxn = 2e5 + 50;
vector<vector<int>> adj(maxn);
vector<int>dp(maxn), s(maxn), vis(maxn), vis1(maxn);
void dfs(int u) {
dp[u] = s[u];
vis[u] = 1;
for (auto& v : adj[u]) {
if (!vis[v]) {
dfs(v);
dp[u] += dp[v];
}
}
}
void dfs1(int u) {
vis1[u] = 1;
for (auto& v : adj[u]) {
if (!vis1[v]) {
if (dp[v]>=s[u]) dp[v] = dp[u];
dfs(v);
}
}
}
signed main() {
ios_base::sync_with_stdio(0); cin.tie(0);
int n, m; cin >> n >> m;
for (int i = 0; i < n; i++) cin >> s[i];
int save = accumulate(s.begin(), s.end(), 0LL);
for (int i = 0; i < m; i++) {
int u, v; cin >> u >> v;
u--; v--;
adj[u].pb(v); adj[v].pb(u);
}
dfs(0); dfs1(0);
for (int i = 0; i < n; i++) {
cout << (dp[i] == save);
}
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
6 ms |
11220 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
5 ms |
11220 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
6 ms |
11220 KB |
Output is correct |
2 |
Incorrect |
125 ms |
23836 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
6 ms |
11220 KB |
Output is correct |
2 |
Incorrect |
153 ms |
19172 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
6 ms |
11220 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |