#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(int i=0; i<adj[node].size(); i++) {
if(adj[node][i]!=prev) dfsd(adj[node][i], node);
}
}
void euler(ll node, ll prev) {
if(d[node]) mark(node);
for(int i=0; i<adj[node].size(); i++) {
if(adj[node][i]!=prev) euler(adj[node][i], 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]);
if(mm!=n) while(true);
return rez;
}
int find_next_station(int s, int t, vector<int> c) {
while(true);
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
stations.cpp: In function 'void dfsd(ll, ll)':
stations.cpp:31:16: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
31 | for(int i=0; i<adj[node].size(); i++) {
| ~^~~~~~~~~~~~~~~~~
stations.cpp: In function 'void euler(ll, ll)':
stations.cpp:38:16: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
38 | for(int i=0; i<adj[node].size(); i++) {
| ~^~~~~~~~~~~~~~~~~
stations.cpp: In function 'int find_next_station(int, int, std::vector<int>)':
stations.cpp:63:17: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
63 | for(int i=0; i<c.size(); i++) {
| ~^~~~~~~~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
1439 ms |
2097152 KB |
Execution killed with signal 9 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
3029 ms |
352 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
1425 ms |
2097152 KB |
Execution killed with signal 9 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
3068 ms |
356 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
2087 ms |
2097152 KB |
Execution killed with signal 9 |
2 |
Halted |
0 ms |
0 KB |
- |