제출 #258106

#제출 시각아이디문제언어결과실행 시간메모리
258106dsjong장난감 기차 (IOI17_train)C++14
0 / 100
1970 ms1400 KiB
#include "train.h" #include <bits/stdc++.h> using namespace std; vector<int>a, r; vector<int>adj[5005]; int n, m; bool vis[5005], cycle[5005], una; void dfs(int x){ if(!una) vis[x]=true; una=false; for(int y:adj[x]){ if(!vis[y] && r[y]==0) dfs(y); } } vector<int> who_wins(vector<int> _a, vector<int> _r, vector<int> u, vector<int> v){ n=_a.size(), m=u.size(); a=_a, r=_r; for(int i=0;i<m;i++){ adj[u[i]].push_back(v[i]); } for(int i=0;i<n;i++){ if(r[i]==0){ una=true; memset(vis, false, sizeof vis); dfs(i); if(vis[i]) cycle[i]=true; } } vector<int>ans; for(int i=0;i<n;i++){ bool good=false; memset(vis, false, sizeof vis); una=false; dfs(i); for(int i=0;i<n;i++){ if(cycle[i] && vis[i]) good=true; } if(good) ans.push_back(0); else ans.push_back(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...