# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
311941 | Mackerel_Pike | Stations (IOI20_stations) | C++14 | 1184 ms | 1116 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 "stations.h"
#include<bits/stdc++.h>
using namespace std;
#define FOR(i, x, y) for(int i = (x); i < (y); ++i)
#define REP(i, x, y) for(int i = (x); i <= (y); ++i)
#define PB push_back
#define MP make_pair
#define PH push
#define fst first
#define snd second
typedef long long ll;
typedef unsigned long long ull;
typedef double db;
typedef long double ldb;
typedef pair<int, int> pii;
const int maxn = 1005;
int clk = 0;
int in[maxn], out[maxn];
vector<int> ans;
vector<int> g[maxn];
void dfs(int u, int p, int d){
in[u] = ++clk;
FOR(i, 0, g[u].size()){
int v = g[u][i];
if(v == p)
continue;
dfs(v, u, d + 1);
}
out[u] = ++clk;
if(d & 1)
ans[u] = out[u];
else
ans[u] = in[u];
return;
}
vector<int> label(int n, int k, vector<int> u, vector<int> v){
FOR(i, 0, n)
g[i].clear();
clk = 0;
FOR(i, 0, n - 1){
int u_ = u[i], v_ = v[i];
g[u_].PB(v_);
g[v_].PB(u_);
}
ans.resize(n);
dfs(0, -1, 0);
vector<int> tmp = ans;
sort(tmp.begin(), tmp.end());
FOR(i, 0, n)
ans[i] = lower_bound(tmp.begin(), tmp.end(), ans[i]) - tmp.begin();
return ans;
}
int find_next_station(int s, int t, vector<int> c){
if(s <= c[0]){
FOR(i, 0, c.size() - 1) if(t >= s && t <= c[i])
return c[i];
return c[c.size() - 1];
}
else{
for(int i = c.size() - 1; i; --i) if(t >= c[i] && t <= s)
return c[i];
return c[0];
}
}
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... |