# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
612073 | daria | Stations (IOI20_stations) | C++14 | 939 ms | 1072 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"
#include <vector>
using namespace std;
const int N = 2001;
int T;
vector<int> adj[N], lb(N);
vector<bool> vis(N);
void dfs(int s, bool b){ //b = 0 apertura, b = 1 chiusura
if(vis[s]) return;
vis[s] = 1;
if(!b) lb[s] = T; T++;
for(int u : adj[s]) dfs(u, 1-b);
if(b) lb[s] = T+N; T++;
}
vector<int> label(int n, int k, vector<int> u, vector<int> v) {
for(int i=0; i<n; ++i) adj[i].clear();
lb.resize(n);
fill(lb.begin(), lb.end(), -1);
fill(vis.begin(), vis.end(), 0);
T = 0;
for(int i=0; i<n-1; ++i){
adj[u[i]].push_back(v[i]);
adj[v[i]].push_back(u[i]);
}
dfs(0, 0);
//for(int i=0; i<n; ++i) cout << i << " " << lb[i] << endl;
return lb;
}
int find_next_station(int s, int t, vector<int> c) {
int par=-1;
if(s < N){ //s apertura
// le altre sono tutte chiusure
par = 0;
for(int u : c) par = max(par, u);
if(t>=N) t-=N;
if(t < s) return par;
t+=N;
for(int i=0; i<c.size(); ++i) if(c[i] >= t) return c[i];
} else{ // s chiusura
// le altre sono tutte aperture
par = 400001;
for(int u : c) par = min(par, u);
if(t<N) t+=N;
if(t > s) return par;
t-=N;
for(int i=c.size()-1; i>=0; --i) if(c[i] <= t) return c[i];
}
return par;
}
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... |