# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1080040 | KaleemRazaSyed | Stations (IOI20_stations) | C++17 | 622 ms | 800 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>
#include "stations.h"
using namespace std;
const int N = 1005;
vector<int> G[N];
int in[N], out[N];
int emit = 0;
void add_edge(int x, int y)
{
G[x].push_back(y);
G[y].push_back(x);
}
void dfs(int v, int p = -1)
{
// cerr << v << endl;
in[v] = emit++;
for(int u : G[v])
if(u != p)
dfs(u, v);
out[v] = emit;
}
vector<int> label(int n, int k, vector<int> u, vector<int> v)
{
for(int i = 0; i < n; i ++)
G[i].clear();
for(int i = 0; i < u.size(); i ++)
add_edge(u[i], v[i]);
dfs(0);
vector<int> l(n);
for(int i = 0; i < n; i ++)
{
l[i] = in[i] * N + out[i];
assert(out[i] < N);
}
return l;
}
int find_next_station(int s, int t, vector<int> c)
{
int ins = s / N, outs = s % N;
int in_t = t / N, outt = t % N;
int p = -1;
for(int i : c)
{
int ini = i / N, outi = i % N;
if(ini <= ins && outs <= outi)
{
p = i;
continue;
}
if(ini <= in_t && outt <= outi)
return i;
}
assert(p != -1);
return p;
}
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... |