#include <bits/stdc++.h>
#include "stations.h"
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
#define N 100005
#define PB push_back
#define sz(x) int(x.size())
#define F first
#define M ll(1e9 + 7)
#define S second
#define all(x) x.begin(), x.end()
#define endl '\n'
//#pragma GCC optimize("unroll-loops")
//#pragma GCC optimize("-O3")
//#pragma GCC optimize("Ofast")
//#pragma GCC optimize("fast-math")
//#pragma GCC optimize("no-stack-protector")
using namespace std;
//using namespace __gnu_pbds;
typedef long long ll;
//typedef tree <int, null_type, less_equal <int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
ll mlt(ll x, ll y) {return (x * y) % M;}
ll sm(ll x, ll y) {return (x + y) % M;}
vector <int> g[N], a;
int id = 0;
void dfs(int v, int p)
{
a[v] = id++;
for (auto it : g[v])
{
if (it == p) continue;
dfs(it, v);
}
}
vector<int> label(int n, int k, vector<int> u, vector<int> v)
{
a.resize(n);
id = 0;
for (int i = 0; i < n - 1; i++)
{
g[u[i]].PB(v[i]);
g[v[i]].PB(u[i]);
}
bool f = 1;
for (int i = 0; i < n; i++) if (sz(g[i]) > 2) f = 0;
if (f)
{
for (int i = 0; i < n; i++)
if (sz(g[i]) == 1) {dfs(i, -1); break;}
}
else
for (int i = 0; i < n; i++) if (sz(g[i]) > 2) dfs(i, -1);
for (int i = 0; i < n; i++) g[i].clear();
return a;
}
int find_next_station(int s, int t, vector<int> c)
{
if (sz(c) == 1) return c[0];
if (sz(c) == 2)
{
sort(all(c));
if (t < c[1]) return c[0];
return c[1];
}
if (sz(c) == 3)
{
sort(all(c));
if (t < c[1]) return c[0];
if (t < c[2]) return c[1];
return c[2];
}
}
//int main()
//{
// iostream::sync_with_stdio(0); ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
//
// //freopen("fcolor.in", "r", stdin); freopen("fcolor.out", "w", stdout);
//
//
//}
Compilation message
stations.cpp: In function 'int find_next_station(int, int, std::vector<int>)':
stations.cpp:101:1: warning: control reaches end of non-void function [-Wreturn-type]
101 | }
| ^
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
569 ms |
5732 KB |
Output is correct |
2 |
Correct |
501 ms |
5732 KB |
Output is correct |
3 |
Correct |
1004 ms |
5504 KB |
Output is correct |
4 |
Correct |
701 ms |
5376 KB |
Output is correct |
5 |
Correct |
661 ms |
5588 KB |
Output is correct |
6 |
Correct |
572 ms |
5616 KB |
Output is correct |
7 |
Correct |
559 ms |
5748 KB |
Output is correct |
8 |
Correct |
5 ms |
5504 KB |
Output is correct |
9 |
Correct |
8 ms |
5584 KB |
Output is correct |
10 |
Correct |
4 ms |
5504 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
42 ms |
2688 KB |
Invalid labels (values out of range). scenario=0, k=1000, vertex=0, label=493028 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
531 ms |
5840 KB |
Output is correct |
2 |
Correct |
550 ms |
5736 KB |
Output is correct |
3 |
Correct |
899 ms |
5584 KB |
Output is correct |
4 |
Correct |
745 ms |
5504 KB |
Output is correct |
5 |
Correct |
565 ms |
5504 KB |
Output is correct |
6 |
Correct |
464 ms |
5740 KB |
Output is correct |
7 |
Correct |
466 ms |
5748 KB |
Output is correct |
8 |
Correct |
5 ms |
5504 KB |
Output is correct |
9 |
Correct |
7 ms |
5504 KB |
Output is correct |
10 |
Correct |
4 ms |
5504 KB |
Output is correct |
11 |
Correct |
597 ms |
5588 KB |
Output is correct |
12 |
Incorrect |
464 ms |
5744 KB |
Wrong query response. |
13 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
951 ms |
5616 KB |
Output is correct |
2 |
Correct |
787 ms |
5588 KB |
Output is correct |
3 |
Correct |
592 ms |
5584 KB |
Output is correct |
4 |
Correct |
5 ms |
5600 KB |
Output is correct |
5 |
Correct |
7 ms |
5504 KB |
Output is correct |
6 |
Correct |
4 ms |
5600 KB |
Output is correct |
7 |
Correct |
630 ms |
5504 KB |
Output is correct |
8 |
Correct |
855 ms |
5588 KB |
Output is correct |
9 |
Correct |
666 ms |
5504 KB |
Output is correct |
10 |
Correct |
691 ms |
5740 KB |
Output is correct |
11 |
Incorrect |
8 ms |
5504 KB |
Wrong query response. |
12 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
671 ms |
5632 KB |
Output is correct |
2 |
Correct |
514 ms |
5720 KB |
Output is correct |
3 |
Correct |
962 ms |
5436 KB |
Output is correct |
4 |
Correct |
745 ms |
5588 KB |
Output is correct |
5 |
Correct |
771 ms |
5588 KB |
Output is correct |
6 |
Correct |
565 ms |
5744 KB |
Output is correct |
7 |
Correct |
537 ms |
5752 KB |
Output is correct |
8 |
Correct |
5 ms |
5596 KB |
Output is correct |
9 |
Correct |
8 ms |
5592 KB |
Output is correct |
10 |
Correct |
4 ms |
5588 KB |
Output is correct |
11 |
Incorrect |
520 ms |
5376 KB |
Wrong query response. |
12 |
Halted |
0 ms |
0 KB |
- |