Submission #1076901

#TimeUsernameProblemLanguageResultExecution timeMemory
1076901GrayToy Train (IOI17_train)C++17
0 / 100
5 ms1884 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; } 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); for (ll i=0; i<n; i++){ 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...