# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
429291 | Dremix10 | Toy Train (IOI17_train) | C++17 | 10 ms | 1484 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 "train.h"
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef pair<int,int> pi;
typedef pair<ll,ll> pl;
#define F first
#define S second
#define endl '\n'
#define all(x) (x).begin(),(x).end()
#ifdef dremix
#define p(x) cerr<<#x<<" = "<<x<<endl;
#define p2(x,y) cerr<<#x<<", "<<#y<<" = {"<<x<<", "<<y<<"}"<<endl;
#define pp(x) cerr<<#x<<" = "<<"("<<x.F<<" - "<<x.S<<")"<<endl;
#define pv(x) cerr<<#x<<" = "<<"{";for(auto y : x)cerr<<y<<", ";cerr<<"}"<<endl;
#define ppv(x) cerr<<#x<<" = "<<"{";for(auto y : x)cerr<<y.F<<"-"<<y.S<<", ";cerr<<"}"<<endl;
#else
#define p(x)
#define p2(x,y)
#define pp(x)
#define pv(x)
#define ppv(x)
#endif
#define fastio ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
const int maxp = 22;
const ld EPS = 1e-9;
const ll INF = 1e18;
const int MOD = 1e9+7;
const int N = 5001;
vector<vector<int> > adj(N);
vector<int> who_wins(vector<int> a, vector<int> r, vector<int> u, vector<int> v) {
int n = a.size();
int m = u.size();
int i,j;
for(i=0;i<m;i++){
int x = u[i];
int y = v[i];
assert(x<=y);
adj[x].push_back(y);
}
vector<int> ans(n);
for(i=0;i<n;i++){
bool self = false;
bool nxt = false;
for(auto x : adj[i])
if(x==i)self = true;
else nxt = true;
bool win = false;
if(a[i] && self && r[i])
win = true;
if(i>0 && a[i] && ans[i-1] && nxt)
win = true;
if((!self || self && r[i]) && (i==0 || !nxt || nxt && i>0 && ans[i-1]))
win = true;
ans[i] = win;
}
return ans;
/*
g++ grader.cpp trainSub.cpp -Ddremix
*/
}
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... |