Submission #750595

#TimeUsernameProblemLanguageResultExecution timeMemory
750595Rasoul006Stranded Far From Home (BOI22_island)C++17
0 / 100
286 ms524288 KiB
#include <bits/stdc++.h> #define endl "\n" #define F first #define S second #define pb push_back #define all(x) x.begin() , x.end() #define mm(dp , val) memset (dp , val , sizeof dp) #define mid ((r+l)>>1) #define lx (n<<1) #define rx ((n<<1)|1) #define low (i&(-i)) #define lb lower_bound #define ub upper_bound #define no void (cout << "NO" << endl) #define one void (cout << "-1" << endl) #define zer void (cout << "0" << endl) #define yes void (cout << "YES" << endl) typedef long long ll; using namespace std; const int logn = 26 ; const int N = 1e6+5; const int mod = 1e9+7; const long long oo = 4557430888798830399 ; ll dx[] = {0 , 0 , 1 , -1}; ll dy[] = {1 , -1 , 0 , 0}; ll n , m , a[N] , pa[N] , sz[N] ; vector <ll> g[N] ; void dfs (ll u , ll p) { pa[u] = p ; sz[u] = a[u] ; for (auto it : g[u]) { if (it == p) continue ; dfs(it , u) ; sz[u] += sz[it] ; } } int main() { ios::sync_with_stdio(0);cin.tie(0);cout.tie(0); cin >> n >> m ; string s = "" ; for (int i = 1 ; i<=n ; i++) cin >> a[i] ; for (int i = 0 ; i<m ; i++) { ll u , v ; cin >> u >> v ; g[u].pb(v) ; g[v].pb(u) ; } dfs (1 , 1) ; s[0] = '1' ; for (int i = 2 ; i<=n ; i++) s[i-1] = (a[pa[i]] <= sz[i] ? '1' : '0') ; cout << s << endl ; return 0; }
#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...