제출 #704005

#제출 시각아이디문제언어결과실행 시간메모리
704005Abrar_Al_Samit장난감 기차 (IOI17_train)C++17
11 / 100
2070 ms1848 KiB
#include<bits/stdc++.h> #include "train.h" using namespace std; const int nax = 5000; int n, m; vector<int>g[nax], gt[nax]; vector<int>A, R; vector<int> who_wins(vector<int> a, vector<int> r, vector<int> u, vector<int> v) { n = a.size(), m = u.size(); for(int i=0; i<m; ++i) { g[u[i]].push_back(v[i]); gt[v[i]].push_back(u[i]); } A = a, R = r; vector<int>res(n); set<int>nontrap, trap; for(int i=0; i<n; ++i) { if(R[i]) nontrap.insert(i); else trap.insert(i); } while(1) { vector<int>trans; for(int x : trap) { bool all = true, one = false; for(int to : g[x]) { all &= nontrap.count(to); one |= nontrap.count(to); } if(A[x] && one) { trans.push_back(x); } else if(!A[x] && all) { trans.push_back(x); } } if(trans.empty()) break; for(int x : trans) { trap.erase(x); nontrap.insert(x); } } while(1) { vector<int>trans; for(int x : nontrap) { bool all = true, one = false; for(int to : g[x]) { all &= trap.count(to); one |= trap.count(to); } if(A[x] && all) { trans.push_back(x); } else if(!A[x] && one) { trans.push_back(x); } } if(trans.empty()) break; for(int x : trans) { trap.insert(x); nontrap.erase(x); } } for(int x : nontrap) res[x] = 1; 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...