Submission #1025891

#TimeUsernameProblemLanguageResultExecution timeMemory
1025891parsadox2Toy Train (IOI17_train)C++17
11 / 100
1538 ms1780 KiB
#include "train.h" #include <bits/stdc++.h> using namespace std; const int N = 5e3 + 10; int n , m , st; vector <int> adj[N]; bool dead[N] , marked[N] , cyc[N]; bool vis[N][2]; void Dfs(int v , int ty) { vis[v][ty] = true; if(dead[v] && ty == 0) { Dfs(v , 1); return; } for(auto u : adj[v]) { if(u == st && ty == 1) cyc[st] = true; if(!vis[u][ty]) Dfs(u , ty); } } bool Solve(int v) { marked[v] = true; if(cyc[v]) return true; bool flg = false; for(auto u : adj[v]) if(!marked[u]) flg |= Solve(u); return flg; } vector<int> who_wins(vector<int> a, vector<int> r, vector<int> u, vector<int> v) { n = a.size(); m = u.size(); vector<int> res(a.size()); for(int i = 0 ; i < n ; i++) dead[i] = r[i]; for(int i = 0 ; i < m ; i++) adj[u[i]].push_back(v[i]); for(int i = 0 ; i < n ; i++) { //cout << "DFS " << i << endl; st = i; for(int j = 0 ; j < n ; j++) vis[j][0] = vis[j][1] = false; Dfs(i , 0); } for(int i = 0 ; i < n ; i++) { memset(marked , false , sizeof marked); res[i] = Solve(i); } return res; }
#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...