#include "stations.h"
#include <vector>
#include <iostream>
#include <cstring>
using namespace std;
vector<vector<int>> g(1000+10);
vector<int> l(10000 +10);
void dfs(int node, int i, int p)
{
l[node] = i;
for(int y : g[node])
{
if(y != p)
{
dfs(y, i+1, node);
}
}
}
vector<int> label(int n, int k, vector<int> u, vector<int> v)
{
vector<int> labels(n);
l.resize(n);
for(int i = 0; i < n-1; i++)
{
g[u[i]].push_back(v[i]);
g[v[i]].push_back(u[i]);
}
int spn = 0;
for(int i = 0; i < n; i++)
{
if(g[i].size() == 1)
{
spn = i;
break;
}
}
dfs(spn, 0, -1);
//cout<<"hola"<<endl;
for (int i = 0; i < n; i++)
{
labels[i] = l[i];
//cout<<"l[i] "<<l[i]<<" lb i "<<labels[l[i]]<<endl;
}
//cout<<"---------"<<endl;
for(int i=0; i<n; i++) g[i].clear();
return labels;
}
int find_next_station(int s, int t, vector<int> c)
{
if(t>s)return s+1;
return s-1;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
484 ms |
676 KB |
Output is correct |
2 |
Correct |
415 ms |
784 KB |
Output is correct |
3 |
Correct |
881 ms |
656 KB |
Output is correct |
4 |
Correct |
645 ms |
776 KB |
Output is correct |
5 |
Correct |
574 ms |
656 KB |
Output is correct |
6 |
Correct |
447 ms |
692 KB |
Output is correct |
7 |
Correct |
466 ms |
656 KB |
Output is correct |
8 |
Correct |
3 ms |
736 KB |
Output is correct |
9 |
Correct |
4 ms |
724 KB |
Output is correct |
10 |
Correct |
1 ms |
732 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
5 ms |
328 KB |
Invalid labels (duplicates values). scenario=0, label=10 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
517 ms |
680 KB |
Output is correct |
2 |
Correct |
444 ms |
656 KB |
Output is correct |
3 |
Correct |
920 ms |
656 KB |
Output is correct |
4 |
Correct |
582 ms |
680 KB |
Output is correct |
5 |
Correct |
569 ms |
656 KB |
Output is correct |
6 |
Correct |
430 ms |
656 KB |
Output is correct |
7 |
Correct |
411 ms |
656 KB |
Output is correct |
8 |
Correct |
3 ms |
724 KB |
Output is correct |
9 |
Correct |
4 ms |
724 KB |
Output is correct |
10 |
Correct |
1 ms |
732 KB |
Output is correct |
11 |
Incorrect |
1 ms |
352 KB |
Invalid labels (duplicates values). scenario=1, label=2 |
12 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
850 ms |
656 KB |
Output is correct |
2 |
Correct |
615 ms |
676 KB |
Output is correct |
3 |
Correct |
603 ms |
784 KB |
Output is correct |
4 |
Correct |
3 ms |
724 KB |
Output is correct |
5 |
Correct |
5 ms |
732 KB |
Output is correct |
6 |
Correct |
1 ms |
724 KB |
Output is correct |
7 |
Incorrect |
1 ms |
328 KB |
Invalid labels (duplicates values). scenario=0, label=2 |
8 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
506 ms |
656 KB |
Output is correct |
2 |
Correct |
434 ms |
784 KB |
Output is correct |
3 |
Correct |
881 ms |
672 KB |
Output is correct |
4 |
Correct |
691 ms |
732 KB |
Output is correct |
5 |
Correct |
581 ms |
680 KB |
Output is correct |
6 |
Correct |
431 ms |
656 KB |
Output is correct |
7 |
Correct |
420 ms |
656 KB |
Output is correct |
8 |
Correct |
3 ms |
724 KB |
Output is correct |
9 |
Correct |
4 ms |
724 KB |
Output is correct |
10 |
Correct |
1 ms |
732 KB |
Output is correct |
11 |
Incorrect |
4 ms |
328 KB |
Invalid labels (duplicates values). scenario=0, label=10 |
12 |
Halted |
0 ms |
0 KB |
- |