#include "stations.h"
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
#define X first
#define Y second
#define ALL(v) v.begin(),v.end()
#define pb push_back
#define SZ(a) ((int)a.size())
const int C=1000;
vector<int> G[1005],idx;
int dft;
void dfs(int u,int f)
{
idx[u]=++dft;
for(int i:G[u])
if(i!=f)
dfs(i,u);
}
vector<int> label(int n, int k, vector<int> u, vector<int> v)
{
idx.resize(n),dft=-1;
for(int i=0;i<n;++i)
G[i].clear();
for(int i=0;i+1<n;++i)
G[u[i]].pb(v[i]),G[v[i]].pb(u[i]);
for(int i=0;i<n;++i)
if(SZ(G[i])==1)
{
dfs(i,i);
break;
}
return idx;
}
int find_next_station(int s, int t, vector<int> c)
{
if(s>t)
return *min_element(ALL(c));
else
return *max_element(ALL(c));
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
648 ms |
768 KB |
Output is correct |
2 |
Correct |
559 ms |
1008 KB |
Output is correct |
3 |
Correct |
894 ms |
768 KB |
Output is correct |
4 |
Correct |
763 ms |
800 KB |
Output is correct |
5 |
Correct |
570 ms |
768 KB |
Output is correct |
6 |
Correct |
502 ms |
768 KB |
Output is correct |
7 |
Correct |
474 ms |
784 KB |
Output is correct |
8 |
Correct |
2 ms |
876 KB |
Output is correct |
9 |
Correct |
5 ms |
768 KB |
Output is correct |
10 |
Correct |
1 ms |
888 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
434 ms |
812 KB |
Wrong query response. |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
595 ms |
1024 KB |
Output is correct |
2 |
Correct |
457 ms |
1008 KB |
Output is correct |
3 |
Correct |
885 ms |
768 KB |
Output is correct |
4 |
Correct |
662 ms |
1140 KB |
Output is correct |
5 |
Correct |
617 ms |
768 KB |
Output is correct |
6 |
Correct |
477 ms |
768 KB |
Output is correct |
7 |
Correct |
453 ms |
768 KB |
Output is correct |
8 |
Correct |
3 ms |
768 KB |
Output is correct |
9 |
Correct |
5 ms |
768 KB |
Output is correct |
10 |
Correct |
1 ms |
768 KB |
Output is correct |
11 |
Incorrect |
577 ms |
768 KB |
Wrong query response. |
12 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1019 ms |
880 KB |
Output is correct |
2 |
Correct |
675 ms |
872 KB |
Output is correct |
3 |
Correct |
826 ms |
768 KB |
Output is correct |
4 |
Correct |
3 ms |
768 KB |
Output is correct |
5 |
Correct |
4 ms |
768 KB |
Output is correct |
6 |
Correct |
2 ms |
880 KB |
Output is correct |
7 |
Incorrect |
628 ms |
904 KB |
Wrong query response. |
8 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
664 ms |
1024 KB |
Output is correct |
2 |
Correct |
456 ms |
768 KB |
Output is correct |
3 |
Correct |
962 ms |
876 KB |
Output is correct |
4 |
Correct |
726 ms |
1024 KB |
Output is correct |
5 |
Correct |
719 ms |
880 KB |
Output is correct |
6 |
Correct |
503 ms |
768 KB |
Output is correct |
7 |
Correct |
443 ms |
788 KB |
Output is correct |
8 |
Correct |
3 ms |
908 KB |
Output is correct |
9 |
Correct |
5 ms |
768 KB |
Output is correct |
10 |
Correct |
2 ms |
876 KB |
Output is correct |
11 |
Incorrect |
532 ms |
832 KB |
Wrong query response. |
12 |
Halted |
0 ms |
0 KB |
- |