Submission #65513

#TimeUsernameProblemLanguageResultExecution timeMemory
65513gs13068Toy Train (IOI17_train)C++17
15 / 100
2074 ms1596 KiB
#include <vector> using namespace std; int d[2][5005], s[5005]; vector<int> g[5005]; vector<int> who_wins(vector<int> a, vector<int> r, vector<int> u, vector<int> v) { int i, j, n = a.size(), m = u.size(); int *p = d[0], *q = d[1], *t; for (i = 0; i < m; i++) g[u[i]].push_back(v[i]); for (i = 0; i < n; i++) { for (j = 0; j < n; j++) { if (a[j]) { q[j] = 0; for (auto t : g[j]) if (p[t] > q[j]) q[j] = p[t]; } else { q[j] = 1e9; for (auto t : g[j]) if (p[t] < q[j]) q[j] = p[t]; } if (r[j]) q[j]++; } t = p; p = q; q = t; } for (i = 0; i < n; i++) s[i] = p[i]; for (i = 0; i < n + n; i++) { for (j = 0; j < n; j++) { if (a[j]) { q[j] = 0; for (auto t : g[j]) if (p[t] > q[j]) q[j] = p[t]; } else { q[j] = 1e9; for (auto t : g[j]) if (p[t] < q[j]) q[j] = p[t]; } if (r[j]) q[j]++; } t = p; p = q; q = t; } vector<int> ans; for (i = 0; i < n; i++) ans.push_back(p[i] > s[i]); 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...