Submission #294166

#TimeUsernameProblemLanguageResultExecution timeMemory
294166ASDF123Toy Train (IOI17_train)C++17
0 / 100
2082 ms2048 KiB
#include "train.h" #include <bits/stdc++.h> #define fr first #define sc second #define pii pair<int, int> #define szof(s) (int)s.size() #define all(s) s.begin(), s.end() using namespace std; typedef vector<int> vi; const int MAXN = 5001; struct LineSolve { vi a, r, u, v; int n, m; vector <int> g[MAXN]; vector <int> rg[MAXN]; LineSolve (vi A, vi R, vi U, vi V) { a = A; r = R; u = U; v = V; n = szof(a); m = szof(u); for (int i = 0; i < m; i++) { g[u[i]].push_back(v[i]); rg[v[i]].push_back(u[i]); } } void solve(vector <int> &ans) { vector <bool> used(MAXN, false); vector <int> ends; for (int i = 0; i < m; i++) { if (u[i] == v[i]) { ends.push_back(u[i]); } } for (int x : ends) { vector <int> path = {}; int answer = r[x]; ans[x] = answer; if (szof(rg[x]) == 2) { int v =(rg[x][0] == x ? rg[x][1] : rg[x][0]); while(1) { ans[v] = answer; if (szof(rg[v]) == 0) { break; } v = rg[v][0]; } } } } }; vi who_wins(vi a, vi r, vi u, vi v) { vi res(a.size(), -1); LineSolve subtask1(a, r, u, v); subtask1.solve(res); return res; } //signed main() { //}
#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...