제출 #1128927

#제출 시각아이디문제언어결과실행 시간메모리
1128927ByeWorldStranded Far From Home (BOI22_island)C++20
0 / 100
1105 ms589824 KiB
#include <bits/stdc++.h> #pragma GCC optimize("O3") #define int long long #define ll long long #define pb push_back #define fi first #define se second #define lf (id<<1) #define rg ((id<<1)|1) #define md ((l+r)>>1) #define ld long double using namespace std; typedef pair<int,int> pii; typedef pair<char,char> pcc; typedef pair<int,pii> ipii; typedef pair<pii,pii> ipiii; const int MAXN = 3e5+10; const int MAXA = 1e6; const int INF = 1e18+10; const int MOD = 1e9+7; const int LOG = 32; const ld EPS = 1e-12; int n, m, a[MAXN], val[MAXN], par[MAXN]; vector <int> adj[MAXN]; void dfs(int nw, int pa){ par[nw] = pa; val[nw] = a[nw]; for(auto nx : adj[nw]){ if(nx==pa) continue; dfs(nx, nw); val[nw] += val[nx]; } // cout << nw << ' ' << val[nw] << " nw\n"; } signed main(){ // ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0); cin >> n >> m; for(int i=1; i<=n; i++) cin >> a[i]; for(int i=1; i<=m; i++){ int x, y; cin >> x >> y; adj[x].pb(y); adj[y].pb(x); } dfs(1, 0); string s = "1"; for(int i=2; i<=n; i++){ if(a[par[i]] > val[i]) s += '0'; else s += '1'; } cout << s << '\n'; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...