Submission #395390

#TimeUsernameProblemLanguageResultExecution timeMemory
395390idk321Toy Train (IOI17_train)C++11
0 / 100
10 ms2084 KiB
#include "train.h" #include <bits/stdc++.h> using namespace std; typedef long long ll; const int N = 5000; set<int> adj[N]; std::vector<int> who_wins(std::vector<int> a, std::vector<int> r, std::vector<int> u, std::vector<int> v) { int n = a.size(); int m = u.size(); bool simple = true; for (int i = 0; i < m; i++) { if (!(v[i] == u[i] || v[i] == u[i] + 1)) simple = false; adj[u[i]].insert(v[i]); } std::vector<int> res(a.size()); //cout << simple << endl; if (simple) { for (int i = 0; i < n; i++) { int cur = i; bool good = false; int travelled = 0; while (travelled < n) { if (a[cur] == 1) { if (r[cur] == 1) { if (adj[cur].find(cur) != adj[cur].end()) { good = true; break; } } for (int next : adj[cur]) { if (next != cur) { cur = next; break; } } } else { if (r[cur] != 1) { if (adj[cur].find(cur) != adj[cur].end()) { break; } } for (int next : adj[cur]) { if (next != cur) { cur = next; break; } } } travelled++; } if (r[cur]) good = true; res[cur] = good; } } 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...