제출 #98881

#제출 시각아이디문제언어결과실행 시간메모리
98881square1001Toy Train (IOI17_train)C++14
0 / 100
1376 ms1272 KiB
#include "train.h" #include <iostream> using namespace std; vector<int> who_wins(vector<int> a, vector<int> r, vector<int> u, vector<int> v) { int n = a.size(), m = u.size(); vector<vector<int> > g(n); for(int i = 0; i < m; ++i) { g[u[i]].push_back(v[i]); } vector<int> ans(n); for(int i = 0; i < n; ++i) { ans[i] = a[i] ^ 1; } vector<int> dp(n, n); for(int i = 0; i < 3 * n; ++i) { vector<int> ndp(n); for(int j = 0; j < n; ++j) { if(a[j] == 1) { ndp[j] = 0; for(int k : g[j]) { ndp[j] = max(ndp[j], dp[k] - 1); } } else { ndp[j] = n; for(int k : g[j]) { ndp[j] = min(ndp[j], dp[k] - 1); } if(ndp[j] < 0) ndp[j] = 0; } if(i < n && ndp[j] > 0) { ndp[j] = n; } } if(i == n - 1) { for(int i = 0; i < n; ++i) { if(ndp[i] > 0) ndp[i] = n; } } if(i >= n - 1) { for(int i = 0; i < n; ++i) { if(a[i] == 1 && ndp[i] > 0) ans[i] = 1; if(a[i] == 0 && ndp[i] == 0) ans[i] = 0; } } dp = ndp; } 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...