제출 #1135441

#제출 시각아이디문제언어결과실행 시간메모리
1135441sonamoo장난감 기차 (IOI17_train)C++20
5 / 100
2095 ms836 KiB
#include "train.h" #include <bits/stdc++.h> #define SIZE 5555 using namespace std; int n , cycle[SIZE] , nxt[SIZE]; vector<int> res; vector<int> who_wins(std::vector<int> a, std::vector<int> r, std::vector<int> u, std::vector<int> v) { n = a.size(); res.resize(n); for (int i = 0; i < n; i++) nxt[i]=-1; for (int i = 0; i < u.size(); i++) { if (u[i] == v[i]) cycle[u[i]]=1; else nxt[u[i]] = v[i]; } //for (int i = 0; i < n; i++) printf("%d %d\n" , cycle[i] , nxt[i]); for (int s = 0; s < n; s++) { int here = s; while(1) { if (cycle[here] == 1 && nxt[here]==-1) { res[s] = r[here]; break; } if (cycle[here]==0 && nxt[here]!=-1) { here = nxt[here]; continue; } if (a[here]==0 && r[here]==0) { res[s] = 0; break; } if (a[here]==1 && r[here]==1) { res[s] = 1; break; } if (a[here]==0 && r[here]==1) { here = nxt[here]; continue; } if (a[here]==1 && r[here]==0) { here = nxt[here]; continue; } } } assert(res.size()==n); 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...