Submission #1037535

#TimeUsernameProblemLanguageResultExecution timeMemory
1037535thinknoexitToy Train (IOI17_train)C++17
0 / 100
471 ms1316 KiB
#include "train.h" #include <bits/stdc++.h> using namespace std; using ll = long long; const int N = 5050; vector<int> adj[N]; bool ans[N], vis[N]; int n, m, rt; void dfs(int v) { vis[v] = 1; for (auto& x : adj[v]) { if (x == rt) { ans[v] = 1; continue; } if (!vis[x]) dfs(x); if (ans[x]) ans[v] = 1; } } vector<int> who_wins(vector<int> a, vector<int> r, vector<int> _U, vector<int> _V) { n = a.size(); m = _U.size(); for (int i = 0;i < m;i++) { adj[_U[i]].push_back(_V[i]); } for (int i = 0;i < n;i++) { if (r[i]) { memset(vis, 0, sizeof vis); rt = i; dfs(i); } } { vector<int> _ans(n); for (int i = 0;i < n;i++) _ans[i] = ans[i]; return _ans; } } /* 4 5 1 0 1 1 0 0 0 1 0 1 1 1 1 2 2 3 3 3 */
#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...