#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) euler(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];
}
}
while(true);
}
Compilation message
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++) {
| ~^~~~~~~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
1459 ms |
2097152 KB |
Execution killed with signal 9 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
3059 ms |
600 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
1640 ms |
2097152 KB |
Execution killed with signal 9 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
644 ms |
684 KB |
Output is correct |
2 |
Runtime error |
1331 ms |
2097152 KB |
Execution killed with signal 9 |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
2754 ms |
2097152 KB |
Execution killed with signal 9 |
2 |
Halted |
0 ms |
0 KB |
- |