Submission #1076906

#TimeUsernameProblemLanguageResultExecution timeMemory
1076906GrayToy Train (IOI17_train)C++17
0 / 100
7 ms1980 KiB
#include "train.h" #include <bits/stdc++.h> using namespace std; #define ll int #define ff first #define ss second #define ln "\n" #define ld long double vector<ll> are; vector<ll> isc; vector<pair<ll, ll>> edge; vector<vector<ll>> A; ll n, m; void dfs(ll u, vector<ll> &vis, vector<ll> &dp, vector<ll> &cnt, ll top){ cnt[u]=top; if (isc[u]) top++; vis[u]=1; dp[u]=0; for (auto i:A[u]){ ll v = edge[i].ff^edge[i].ss^u; if (vis[v]==1) { if (cnt[v]==top) dp[u]=1; continue; }else if (vis[v]==0){ dfs(v, vis, dp, cnt, top); } dp[u]|=dp[v]; } vis[u]=2; } void order(ll u, vector<ll> &vis, vector<ll> &ord){ vis[u]=1; for (auto i:A[u]){ ll v = edge[i].ff^edge[i].ss^u; if(!vis[v]) order(v, vis, ord); } ord.push_back(u); } vector<int> who_wins(vector<int> a, vector<int> r, vector<int> u, vector<int> v) { n=a.size(); m=v.size(); isc=r; are=a; A.clear(); A.resize(n); edge.clear(); edge.resize(m); for (ll i=0; i<m; i++){ edge[i] = {u[i], v[i]}; A[u[i]].push_back(i); } vector<ll> vis(n), dp(n), cnt(n); vector<ll> ord; for (ll i=0; i<n; i++){ if (!vis[i]) order(i, vis, ord); } vis.assign(n, 0); reverse(ord.begin(), ord.end()); for (auto i:ord){ if (!vis[i]){ dfs(i, vis, dp, cnt, 0); } } for (ll i=0; i<n; i++) dp[i]=!dp[i]; return dp; }
#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...
#Verdict Execution timeMemoryGrader output
Fetching results...