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>
#define mp make_pair
#define pb push_back
#define xx first
#define yy second
#define pll pair<long long, long long>
#define MOD 1000000007
typedef long long ll;
using namespace std;
mt19937 mt(time(nullptr));
/*
static int max_label = 0;
static int r, n, k, q;
static std::vector<int> u, v, labels, answers;
static std::map<int, int> reverse_labels;
static std::vector<std::vector<int>> adjlist;
static int s, t, w;
static std::vector<int> c;
*/
vector<int> adj[2000];
bool d[2000];
ll mm, m[2000];
void mark(ll node) {
m[node]=mm;
mm++;
}
void dfsd(ll node, ll prev) {
d[node]=!d[prev];
for(auto cur:adj[node]) {
if(cur!=prev) dfsd(cur, node);
}
}
void euler(ll node, ll prev) {
if(d[node]) mark(node);
for(auto cur:adj[node]) {
if(cur!=prev) dfsd(cur, node);
}
if(!d[node]) mark(node);
}
vector<int> label(int n, int k, vector<int> u, vector<int> v) {
for(int i=0; i<n-1; i++) {
adj[u[i]].pb(v[i]);
adj[v[i]].pb(u[i]);
}
dfsd(0, 0);
euler(0, 0);
vector<int> rez;
for(int i=0; i<n; i++) rez.pb(m[i]);
return rez;
}
int find_next_station(int s, int t, vector<int> c) {
if(c[0]>s) {
if(t<s||t>=c[c.size()-1]) {
return c[c.size()-1];
}
for(int i=0; i<c.size(); i++) {
if(t<=c[i]) return c[i];
}
}
else {
if(t>s||t<=c[0]) {
return c[0];
}
for(int i=c.size()-1; i>=0; i--) {
if(t>=c[i]) return c[i];
}
}
}
Compilation message (stderr)
stations.cpp: In function 'int find_next_station(int, int, std::vector<int>)':
stations.cpp:61:17: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
61 | for(int i=0; i<c.size(); i++) {
| ~^~~~~~~~~
stations.cpp:73:1: warning: control reaches end of non-void function [-Wreturn-type]
73 | }
| ^
# | 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... |