Submission #68304

#TimeUsernameProblemLanguageResultExecution timeMemory
68304aquablitz11Toy Train (IOI17_train)C++14
15 / 100
2080 ms118068 KiB
#include <bits/stdc++.h> #include "train.h" using namespace std; using pii = pair<int, int>; const int N = 5e3+10; int n, m; int deg[N]; vector<int> R[N]; bool used[N][N]; int cnt[N][N]; vector<int> who_wins(vector<int> A, vector<int> C, vector<int> U, vector<int> V) { // input n = A.size(); m = U.size(); for (int i = 0; i < m; ++i) { ++deg[U[i]]; R[V[i]].push_back(U[i]); } // winning position for B queue<pii> Q; for (int i = 0; i < n; ++i) { used[i][0] = true; Q.emplace(i, 0); } while (!Q.empty()) { int u = Q.front().first, p = Q.front().second; Q.pop(); if (!C[u] && p+1 <= n) for (auto v : R[u]) { int np = p+1; if (C[v] && np != n) continue; ++cnt[v][np]; if (cnt[v][np] == (A[v] ? (int)deg[v] : 1) && !used[v][np]) { used[v][np] = true; Q.emplace(v, np); } } if (C[u] && p == n) for (auto v : R[u]) { if (C[v]) { int np = n; ++cnt[v][np]; if (cnt[v][np] == (A[v] ? (int)deg[v] : 1) && !used[v][np]) { used[v][np] = true; Q.emplace(v, np); } } else for (int np = 1; np <= n; ++np) { ++cnt[v][np]; if (cnt[v][np] == (A[v] ? (int)deg[v] : 1) && !used[v][np]) { used[v][np] = true; Q.emplace(v, np); } } } } vector<int> ans(n); for (int i = 0; i < n; ++i) ans[i] = used[i][n] ? 0 : 1; 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...