Submission #583965

#TimeUsernameProblemLanguageResultExecution timeMemory
583965PiejanVDCToy Train (IOI17_train)C++17
11 / 100
600 ms1292 KiB
#include <bits/stdc++.h> #include "train.h" using namespace std; const int mxN = (int)5005; vector<int>adj[mxN]; vector<bool>vis; int t; bool f; vector<int>R; bool dfs(int u) { if(u == t && f) return 1; f = 1; if(vis[u] || R[u]) return 0; vis[u] = 1; for(auto z : adj[u]) { if(dfs(z)) return 1; } return 0; } vector<int>who_wins(vector<int>a, vector<int>r, vector<int>u, vector<int>v) { R = r; int n = r.size(); int m = u.size(); for(int i = 0 ; i < m ; i++) adj[u[i]].push_back(v[i]); vector<int>pos(n,0); for(int i = 0 ; i < n ; i++) { if(!r[i]) { vis.clear(); vis.resize(n,0); t = i; f = 0; pos[i] = dfs(i); } } for(int x = 0 ; x < n ; x++) for(int i = 0 ; i < n ; i++) { for(auto z : adj[i]) pos[i] |= pos[z]; } vector<int>ans(n); for(int i = 0 ; i < n ; i++) ans[i] = 1 - pos[i]; return ans; }
#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...