Submission #423007

#TimeUsernameProblemLanguageResultExecution timeMemory
423007flappybirdToy Train (IOI17_train)C++14
23 / 100
327 ms1892 KiB
#include "train.h" #include <bits/stdc++.h> #pragma GCC optimize("O3") #pragma GCC optimize("Ofast") #pragma GCC optimize("unroll-loops") #pragma GCC target("avx,avx2,fma") using namespace std; typedef int ll; #define MAX 10000 vector<ll> A, s; ll N, M; vector<ll> adj[MAX], rev[MAX], deg, d; std::vector<int> who_wins(std::vector<int> a, std::vector<int> r, std::vector<int> u, std::vector<int> v) { ll i; A = a; N = a.size(); M = u.size(); d.resize(N); deg.resize(N); vector<ll> res; res.resize(N); for (i = 0; i < N; i++) if (r[i]) s.push_back(i); for (i = 0; i < M; i++) adj[u[i]].push_back(v[i]), rev[v[i]].push_back(u[i]), d[u[i]]++; for (auto st : s) { deg = d; queue<ll> q; vector<ll> vis; vis.resize(N); q.push(st); vis[st] = 1; while (!q.empty()) { ll t = q.front(); q.pop(); for (auto x : rev[t]) { if (vis[x]) continue; deg[x]--; if (a[x]) q.push(x), vis[x] = 1; else if (deg[x] == 0) q.push(x), vis[x] = 1; } } bool c = true; if (!a[st]) { for (auto asdf : adj[st]) { if (!vis[asdf]) { c = 0; break; } } } else { c = 0; for (auto asdf : adj[st]) { if (vis[asdf]) { c = 1; break; } } } if (c) { for (i = 0; i < N; i++) res[i] |= vis[i]; } } 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...