Submission #583964

#TimeUsernameProblemLanguageResultExecution timeMemory
583964PiejanVDCToy Train (IOI17_train)C++17
11 / 100
491 ms1356 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; bool dfs(int u) { if(u == t && f) return 1; f = 1; if(vis[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) { 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]; } return pos; }
#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...