제출 #795595

#제출 시각아이디문제언어결과실행 시간메모리
795595fatemetmhr장난감 기차 (IOI17_train)C++17
23 / 100
467 ms18680 KiB
// ~ Be Name Khoda ~ // #include "train.h" #include <bits/stdc++.h> //#pragma GCC optimize ("O3") //#pragma GCC target("avx2") //#pragma GCC optimize("unroll-loops,Ofast") using namespace std; typedef long long ll; #define pb push_back #define mp make_pair #define all(x) x.begin(), x.end() #define fi first #define se second const int maxn = 1e6 + 10; const int maxn5 = 5e3 + 10; const int maxnt = 1.2e6 + 10; const int maxn3 = 1e3 + 10; const int mod = 1e9 + 7; const ll inf = 1e18; int cnt[maxn5], q[maxn5]; vector <int> adj[maxn5], jda[maxn5], ret, a; bool good[maxn5][maxn5]; int n, m; void solve(int x){ for(int i = 0; i < n; i++) cnt[i] = adj[i].size(); int l = 0, r = 0; for(auto u : jda[x]){ if(a[u]){ q[r++] = u; good[x][u] = true; } else if(cnt[u] > 1) cnt[u]--; else{ q[r++] = u; good[x][u] = true; } } while(l < r){ int v = q[l++]; for(auto u : jda[v]) if(!good[x][u]){ if(a[u]){ q[r++] = u; good[x][u] = true; } else if(cnt[u] > 1) cnt[u]--; else{ q[r++] = u; good[x][u] = true; } } } } std::vector<int> who_wins(std::vector<int> A, std::vector<int> ch, std::vector<int> u, std::vector<int> v) { a = A; n = a.size(); m = u.size(); for(int i = 0; i < m; i++){ adj[u[i]].pb(v[i]); jda[v[i]].pb(u[i]); cnt[u[i]]++; } for(int i = 0; i < n; i++) if(ch[i]) solve(i); bool found = false; for(int i = 0; i < n; i++){ bool x = true; for(int j = 0; j < n; j++) if(ch[j] && good[j][i]) x = false; if(x) found = true; } for(int i = 0; i < n; i++){ bool re = false; for(int j = 0; j < n; j++) if(ch[j] && good[j][j] && good[j][i]) re = true; ret.pb(re || !found); } return ret; }
#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...