(UPD: 2024-12-04 14:48 UTC) Judge is not working due to Cloudflare incident. (URL) We can do nothing about it, sorry. After the incident is resolved, we will grade all submissions.

Submission #1122048

#TimeUsernameProblemLanguageResultExecution timeMemory
1122048vjudge1Stranded Far From Home (BOI22_island)C++17
10 / 100
147 ms71240 KiB
#include <map> #include <set> #include <list> #include <cmath> #include <ctime> #include <deque> #include <queue> #include <stack> #include <string> #include <bitset> #include <cstdio> #include <limits> #include <vector> #include <climits> #include <cstring> #include <cstdlib> #include <fstream> #include <numeric> #include <sstream> #include <cassert> #include <iomanip> #include <iostream> #include <algorithm> #include <stdio.h> #include <fstream> #include <unordered_map> using namespace std; #define ll long long #define ff first #define ss second #define pb push_back #define pf push_front #define UseOFF ios_base::sync_with_stdio(0);cin.tie(0), cout.tie(0); #define sz size #define ins insert #define new junkedseduneon #define prev usfdjik const ll N = 2e6 + 111; ll a[N]; vector <ll> v[N]; bool used[N]; bool used2[N]; ll sum[N]; ll r[N]; bool ans[N]; void dfs(ll x, ll p) { used[x] = 1; sum[x] += sum[p]; if(p != 0) sum[x] += a[x]; // if(x == ) { // cout << sum[x] << " " << sum[p] << " " << p << '\n'; // } for(auto to : v[x]) { if(to > x || v[to].sz() > 2) { continue; } dfs(to, x); } } void dfs2(ll x, ll p) { used[x] = 1; sum[x] = a[x] + sum[p]; for(auto to : v[x]) { if(used[to]) continue; if(to > x) { return; } dfs(to, x); } } void solve() { ll n, m; cin >> n >> m; for(int i = 1; i <= n; i++) { cin >> a[i]; } for(int i = 1; i <= m; i++) { ll x, y; cin >> x >> y; if(x < y) swap(x, y); v[x].pb(y); v[y].pb(x); } // if(n <= 2 && m <= 2) { // for(int i = 1; i <= n; i++) { // multiset < pair <ll, ll> > st; // st.ins({a[i], i}); // //cout << x.ff << " " << x.ss << '\n'; // ll cur = 0; // bool bb = 0; // for(int j = 1; j <= n; j++) used[j] = 0; // used[i] = 1; // while(st.sz() > 0) { // vector <ll> g; // pair <ll, ll> x = *st.begin(); // if(cur < x.ff && x.ss != i) { // cout << '0'; // bb = 1; // break; // } // cur += x.ff; // for(auto to : v[x.ss]) { // if(used[to]) continue; // //cout << i << " " << cur << " " << to << " " << x.ss << endl; // st.ins({a[to], to}); // used[to] = 1; // } // st.erase(x); // } // if(st.sz() == 0) { // cout << '1'; // } // } // return; // } for(int i = n; i >= 1; i--) { if(sum[i] == 0) { sum[i] = a[i]; for(auto to : v[i]) { if(to > i) sum[i] += sum[to]; // if(i == 4) { // cout << i << " " << to << " " << sum[to] << " " << sum[i] << '\n'; // } } dfs(i, 0); } //cout << sum[i] << " " << i << " || "; } ans[1] = 1; for(int i = 2; i <= n; i++) { for(auto to : v[i]) { if(to > i) continue; if(ans[to] == 1) { if(sum[i] >= a[to]) { ans[i] = 1; } } } } for(int i = 1; i <= n; i++) { cout << ans[i]; } } signed main() { UseOFF ll ttt = 1; //cin >> ttt; while(ttt--) { solve(); } }
#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...