# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
280361 | Noam13 | Toy Train (IOI17_train) | C++14 | 12 ms | 1280 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
#define vi vector<int>
#define vvi vector<vi>
#define vb vector<bool>
#define vvb vector<vb>
#define ii pair<int, int>
#define x first
#define y second
#define vii vector<ii>
#define pb push_back
#define all(x) x.begin(), x.end()
#define loop(i,s,e) for(int i=s;i<e;++i)
#define loopr(i,s,e) for(int i=e-1;i>=s;--i)
#define chkmin(a,b) a = min(a,b)
#define chkmax(a,b) a = max(a,b)
using namespace std;
const int INF = 1e9;
int n;
vi who_wins(vi a, vi r, vi u, vi v) {
n = a.size();
vvi g(n);
loop(i,0,u.size()){
int a = u[i], b = v[i];
g[a].pb(b);
}
vi res(n); res[n-1] = r[n-1];
loopr(i,0,n-1){
int tmp = -1;
res[i] = r[i];
for(auto nei:g[i]){
if (nei==i){
if ((a[i] ^ r[i]) == 0) tmp = r[i];
}
else res[i] = res[nei];
}
if (tmp!=-1) res[i] = tmp;
}
return res;
}
/*
clear
g++ c.cpp grader.cpp -o c ; ./c
2 4
1 0
0 1
0 0
0 1
1 0
1 1
*/
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |