Submission #304998

# Submission time Handle Problem Language Result Execution time Memory
304998 2020-09-22T11:17:20 Z mhy908 Stations (IOI20_stations) C++14
Compilation error
0 ms 0 KB
#include "stations.h"
#include <bits/stdc++.h>
#define mp make_pair
#define eb emplace_back
#define F first
#define S second
#define all(x) x.begin(), x.end()
#define svec(x) sort(all(x))
#define press(x) x.erase(unique(all(x)), x.end());
using namespace std;
typedef long long LL;
typedef pair<int, int> pii;
typedef pair<int, LL> pil;
typedef pair<LL, int> pli;
typedef pair<LL, LL> pll;
const int INF=1e9;
const LL LLINF=1e18;

int n, re;
vector<int> link[1010], lab, id;

void dfs(int num, int par, int d){
    re++;
    if(d)lab[num-1]=re;
    for(auto i:link[num]){
        if(i==par)continue;
        dfs(i, num, (d+1)%2);
    }
    if(!d)lab[num-1]=re;
    re++;
}

vector<int> label(int _n, int k, vector<int> u, vector<int> v){
    n=_n;
	lab.clear();
	id.clear();
	lab.resize(n);
	re=0;
	for(int i=0; i<n-1; i++){
        link[u[i]+1].eb(v[i]+1);
        link[v[i]+1].eb(u[i]+1);
	}
	dfs(1, 0, 1);
	for(int i=1; i<=n; i++)link[i].clear();
	for(auto i:lab)id.eb(i);
	svec(id); press(id);
	for(auto &i:lab)i=lower_bound(all(id), i)-id.begin();
	return lab;
}

int find_next_station(int s, int t, vector<int> c){
	if(s>c.back())reverse(all(c));
    for(int i:c){
        if(min(u, s)<=t&&t<=max(u, s))return u;
    }
    return c.back();
}

/*
1
5 10
0 1
1 2
1 3
2 4
*/

Compilation message

stations.cpp: In function 'int find_next_station(int, int, std::vector<int>)':
stations.cpp:54:16: error: 'u' was not declared in this scope
   54 |         if(min(u, s)<=t&&t<=max(u, s))return u;
      |                ^
stations.cpp:53:13: warning: unused variable 'i' [-Wunused-variable]
   53 |     for(int i:c){
      |             ^