Submission #1034663

#TimeUsernameProblemLanguageResultExecution timeMemory
1034663ALeonidouToy Train (IOI17_train)C++17
11 / 100
308 ms1824 KiB
#include "train.h" #include <bits/stdc++.h> using namespace std; #define ll int #define sz(x) (ll)x.size() #define endl "\n" #define pb push_back #define F first #define S second typedef vector <ll> vi; typedef pair <ll,ll> ii; typedef vector <ii> vii; #define dbg(x) cout<<#x<<": "<<x<<endl; #define dbg2(x,y) cout<<#x<<": "<<x<<" "<<#y<<": "<<y<<endl; #define dbg3(x,y,z) cout<<#x<<": "<<x<<" "<<#y<<": "<<y<<" "<<#z<<": "<<z<<endl; void printVct(vi &v){ for (ll i =0; i<sz(v); i++){ cout<<v[i]<<" "; } cout<<endl; } vector <vi> adj, radj; vi vis; void dfs(ll u){ vis[u] = 1; for (ll i =0; i<sz(radj[u]); i++){ ll c = radj[u][i]; if (!vis[c]){ dfs(c); } } } bool dfs_validation(ll u, ll t){ vis[u] = 1; for (ll i =0; i<sz(adj[u]); i++){ ll c = adj[u][i]; if (!vis[c]){ if (dfs_validation(c, t)) return true; } else if (c == t){ return true; } } return false; } vi who_wins(vi a, vi r, vi u, vi v) { ll n = sz(a), m = sz(u); adj.assign(n,vi()); radj.assign(n, vi()); for(ll i =0; i<m; i++){ // dbg3(i, u[i], v[i]); adj[u[i]].pb(v[i]); radj[v[i]].pb(u[i]); } for (ll i = 0; i<n; i++){ if (r[i]){ vis.assign(n,0); r[i] = dfs_validation(i,i); } } vis.assign(n,0); for (ll i =0; i<n; i++){ if (!vis[i] && r[i]){ dfs(i); } } return vis; } /* 7 9 1 1 1 1 1 1 1 0 1 0 0 0 1 1 0 2 0 1 2 3 1 4 4 5 5 3 3 4 3 6 6 6 */
#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...