#include "stations.h"
#include <vector>
#include <iostream>
using namespace std;
void dfs(int v, int p, int type, int& cur, vector<int>& labels, vector<vector<int> >& adi)
{
if(type == 0)
{
labels[v] = cur;
cur ++;
}
for(int next : adi[v])
{
if(next == p) continue;
dfs(next, v, !type, cur, labels, adi);
}
if(type == 1)
{
labels[v] = cur;
cur ++;
}
cerr << v << " " << type << " " << labels[v] << '\n';
}
vector<int> label(int n, int k, vector<int> u, vector<int> v) {
vector<int> labels(n, -1);
vector<vector<int> > adi(n);
for(int i = 0; i < n - 1; i ++)
{
adi[u[i]].push_back(v[i]);
adi[v[i]].push_back(u[i]);
}
int cur = 0;
dfs(0, -1, 0, cur, labels, adi);
return labels;
}
int find_next_station(int s, int t, vector<int> c)
{
int ans;
if(c[0] > s)
{
int lo = -1, hi = c.size() - 1;
while(lo + 1 < hi)
{
int m = (hi + lo) / 2;
if(c[m] >= t) hi = m;
else lo = m;
}
ans = c[hi];
}
else
{
int lo = 0, hi = c.size();
while(lo + 1 < hi)
{
int m = (hi + lo) / 2;
if(c[m] > t) hi = m;
else lo = m;
}
ans = c[lo];
}
return ans;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
699 ms |
768 KB |
Wrong query response. |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
612 ms |
756 KB |
Wrong query response. |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
713 ms |
704 KB |
Wrong query response. |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
877 ms |
400 KB |
Output is correct |
2 |
Correct |
770 ms |
400 KB |
Output is correct |
3 |
Incorrect |
815 ms |
528 KB |
Wrong query response. |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
801 ms |
652 KB |
Wrong query response. |
2 |
Halted |
0 ms |
0 KB |
- |