Submission #65506

#TimeUsernameProblemLanguageResultExecution timeMemory
65506gs13068Toy Train (IOI17_train)C++17
0 / 100
1396 ms1404 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] == 1) { 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; i++) { for (j = 0; j < n; j++) { if (a[j] == 1) { 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] ? 1 : 2); 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...