Submission #1060343

#TimeUsernameProblemLanguageResultExecution timeMemory
1060343ZicrusToy Train (IOI17_train)C++17
11 / 100
602 ms2136 KiB
#include <bits/stdc++.h> #include "train.h" using namespace std; typedef long long ll; vector<vector<ll>> adj, revAdj; vector<bool> vst; bool poss = false; void dfs1(ll cur, ll root) { vst[cur] = true; for (auto &e : revAdj[cur]) { if (e == root) poss = true; if (vst[e]) continue; dfs1(e, root); } } vector<int> who_wins(vector<int> a, vector<int> r, vector<int> u, vector<int> v) { ll n = a.size(), m = u.size(); vector<int> res(n); adj = vector<vector<ll>>(n); revAdj = vector<vector<ll>>(n); for (int i = 0; i < m; i++) { adj[u[i]].push_back(v[i]); revAdj[v[i]].push_back(u[i]); } for (int i = 0; i < n; i++) { if (!r[i]) continue; vst = vector<bool>(n); poss = false; dfs1(i, i); if (poss) { for (int j = 0; j < n; j++) { if (!vst[j]) continue; res[j] = true; } } } 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...