Submission #139970

#TimeUsernameProblemLanguageResultExecution timeMemory
139970shashwatchandraToy Train (IOI17_train)C++17
0 / 100
1387 ms25952 KiB
#include "train.h" #include <bits/stdc++.h> using namespace std; #define pb push_back #define REP(i,n) for(int i = 0;i < n;i++) const int N = 5001; bool reach[N][N]; int n,m; vector<int> adj[N]; int source = 0; void dfs(int u){ for(int v:adj[u]){ if(reach[source][v])continue; reach[source][v] = 1; dfs(v); } } vector<int> who_wins(vector<int> a, vector<int> r,vector<int> u, vector<int> v) { n = a.size(); m = u.size(); REP(i,m){ adj[u[i]].pb(v[i]); } while(source < n){ dfs(source); source++; } vector<int> ans; REP(i,n){ bool done = 0; REP(j,n){ if(!a[j])continue; if(reach[i][j] and reach[j][i]){ done = 1; } } ans.pb(done); } 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...