| # | Time | Username | Problem | Language | Result | Execution time | Memory |
|---|---|---|---|---|---|---|---|
| 1310006 | lnw143 | 장난감 기차 (IOI17_train) | C++17 | 0 ms | 0 KiB |
#include "train.h"
#include <bits/stdc++.h>
using namespace std;
using vi=vector<int>;
const int N=5005;
int n,m;
vi who_wins(vi a,vi r,vi u,vi v) {
n=a.size(),m=u.size();
const auto check1=[&]() {
for(int i=0; i<m; ++i) if(u[i]!=v[i]&&u[i]+1!=v[i]) return 0;
return 1;
};
if(check1()) {
static int bz[N];
for(int i=0; i<m; ++i) if(u[i]==v[i]) bz[i]|=1; else bz[i]|=2;
vi ans(n,0);
for(int i=n-1; i>=0; --i) {
if((a[i]==r[i]&&(b[i]&1))||(~bz[i]&2)) ans[i]=r[i];
else ans[i]=ans[i+1];
}
return ans;
}
return res;
}
