#include "stations.h"
#include <vector>
#include <iostream>
#include <cstring>
using namespace std;
vector<vector<int>> g(1000+10);
vector<int> l(10000 +10);
bool ch[1010];
void dfs(int node, int i)
{
if(ch[node])return;
ch[node]=true;
l[i] = node;
//cout<<node<<endl;
for(int y : g[node])
{
if(!ch[y])
{
dfs(y, i+1);
}
}
}
vector<int> label(int n, int k, vector<int> u, vector<int> v)
{
vector<int> labels(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);
//cout<<"hola"<<endl;
for (int i = 0; i < n; i++)
{
labels[l[i]] = i;
//cout<<"l[i] "<<l[i]<<" lb i "<<labels[l[i]]<<endl;
}
//cout<<"---------"<<endl;
for(int i = 0; i<n+2; i++)ch[i]=false;
for(int i=0; i<n; i++) g[i].clear();
l.clear();
return labels;
}
int find_next_station(int s, int t, vector<int> c)
{
if(t>s)return s+1;
return s-1;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
538 ms |
748 KB |
Output is correct |
2 |
Correct |
428 ms |
656 KB |
Output is correct |
3 |
Correct |
928 ms |
660 KB |
Output is correct |
4 |
Correct |
674 ms |
680 KB |
Output is correct |
5 |
Correct |
606 ms |
656 KB |
Output is correct |
6 |
Correct |
435 ms |
656 KB |
Output is correct |
7 |
Correct |
421 ms |
656 KB |
Output is correct |
8 |
Correct |
2 ms |
724 KB |
Output is correct |
9 |
Correct |
4 ms |
720 KB |
Output is correct |
10 |
Correct |
1 ms |
732 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
4 ms |
328 KB |
Invalid labels (duplicates values). scenario=0, label=0 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
509 ms |
680 KB |
Output is correct |
2 |
Correct |
449 ms |
776 KB |
Output is correct |
3 |
Correct |
902 ms |
656 KB |
Output is correct |
4 |
Correct |
621 ms |
688 KB |
Output is correct |
5 |
Correct |
546 ms |
792 KB |
Output is correct |
6 |
Correct |
436 ms |
668 KB |
Output is correct |
7 |
Correct |
415 ms |
656 KB |
Output is correct |
8 |
Correct |
1 ms |
724 KB |
Output is correct |
9 |
Correct |
4 ms |
728 KB |
Output is correct |
10 |
Correct |
1 ms |
724 KB |
Output is correct |
11 |
Incorrect |
1 ms |
328 KB |
Invalid labels (duplicates values). scenario=1, label=0 |
12 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
858 ms |
656 KB |
Output is correct |
2 |
Correct |
658 ms |
676 KB |
Output is correct |
3 |
Correct |
544 ms |
656 KB |
Output is correct |
4 |
Correct |
3 ms |
724 KB |
Output is correct |
5 |
Correct |
4 ms |
724 KB |
Output is correct |
6 |
Correct |
2 ms |
640 KB |
Output is correct |
7 |
Incorrect |
1 ms |
356 KB |
Invalid labels (duplicates values). scenario=3, label=0 |
8 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
543 ms |
876 KB |
Output is correct |
2 |
Correct |
425 ms |
656 KB |
Output is correct |
3 |
Correct |
856 ms |
656 KB |
Output is correct |
4 |
Correct |
658 ms |
656 KB |
Output is correct |
5 |
Correct |
622 ms |
680 KB |
Output is correct |
6 |
Correct |
431 ms |
680 KB |
Output is correct |
7 |
Correct |
483 ms |
656 KB |
Output is correct |
8 |
Correct |
3 ms |
724 KB |
Output is correct |
9 |
Correct |
5 ms |
684 KB |
Output is correct |
10 |
Correct |
1 ms |
724 KB |
Output is correct |
11 |
Incorrect |
5 ms |
328 KB |
Invalid labels (duplicates values). scenario=0, label=0 |
12 |
Halted |
0 ms |
0 KB |
- |