#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
#define db double
#define ll __int128
#define pb push_back
#define fs first
#define sd second
#define Mod long(1e9 + 7)
#define all(x) x.begin(), x.end()
#define unvisited long(-1)
#define Eps double(1e-9)
#define _for(i, n) for(int i = 0; i < (n); i++)
#define dbg(x) cout << #x ": " << x << endl;
const int Max = 1e6 + 7, Inf = 1e9 + 7;
void print(bool x) { cout << (x ? "YES" : "NO") << endl; }
string tostring (__int128 x)
{
string ans = "";
while(x > 0)
{
ans += (x % 10 + '0');
x /= 10;
}
reverse(all(ans));
return ans;
}
vector <vector<int>> fx; vector <int> fy; int idx;
void dfs(int node, int parent, int depth)
{
if(depth % 2 == 0)
{
idx++;
fy[node] = idx;
}
for(auto& u : fx[node]) if(u != parent)
{
dfs(u, node, depth + 1);
}
if(depth % 2 == 1)
{
idx++;
fy[node] = idx;
}
}
void show()
{
cout << "\n Labels: \n";
for(int i = 0; i < (int) fy.size(); i++)
cout << fy[i] << " ";
cout << endl;
}
vector<int> label(int n, int k, vector<int> U, vector<int> V)
{
fx.clear(); fx.assign(n, vector <int> ());
fy.clear(); fy.assign(n, 0); idx = 0;
for(int i = 0; i < n - 1; i++)
{
fx[V[i]].push_back(U[i]);
fx[U[i]].push_back(V[i]);
}
//for(int i = 0; i < n; i++)
//{
// if(fy[i] == 0) dfs(i, -1);
//}
dfs(0, -1, 1);
//show();
return fy;
}
int find_next_station(int s, int t, vector<int> c)
{
int n = (int) c.size(); sort(all(c));
if(s > c[0])
{
for(int i = n - 1; i >= 0; i--)
{
if(c[i] <= t && t <= s)
return c[i];
}
return c[0];
}
else
{
for(int i = 0; i < n; i++)
{
if(s <= t && t <= c[i])
return c[i];
}
return c[n-1];
}
}
/**
1
5 10
0 1
1 2
1 3
2 4
2
2 0 1
1 3 3
9
1
3
*/
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
518 ms |
716 KB |
Output is correct |
2 |
Correct |
399 ms |
620 KB |
Output is correct |
3 |
Correct |
733 ms |
420 KB |
Output is correct |
4 |
Correct |
478 ms |
416 KB |
Output is correct |
5 |
Correct |
525 ms |
500 KB |
Output is correct |
6 |
Correct |
329 ms |
540 KB |
Output is correct |
7 |
Correct |
303 ms |
496 KB |
Output is correct |
8 |
Correct |
1 ms |
492 KB |
Output is correct |
9 |
Correct |
4 ms |
492 KB |
Output is correct |
10 |
Correct |
0 ms |
492 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
268 ms |
632 KB |
Output is correct |
2 |
Correct |
345 ms |
500 KB |
Output is correct |
3 |
Correct |
920 ms |
508 KB |
Output is correct |
4 |
Correct |
589 ms |
476 KB |
Output is correct |
5 |
Correct |
448 ms |
500 KB |
Output is correct |
6 |
Correct |
420 ms |
500 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
391 ms |
676 KB |
Output is correct |
2 |
Correct |
415 ms |
624 KB |
Output is correct |
3 |
Correct |
517 ms |
420 KB |
Output is correct |
4 |
Correct |
513 ms |
504 KB |
Output is correct |
5 |
Correct |
537 ms |
504 KB |
Output is correct |
6 |
Correct |
404 ms |
636 KB |
Output is correct |
7 |
Correct |
300 ms |
548 KB |
Output is correct |
8 |
Correct |
1 ms |
500 KB |
Output is correct |
9 |
Correct |
3 ms |
492 KB |
Output is correct |
10 |
Correct |
1 ms |
464 KB |
Output is correct |
11 |
Correct |
457 ms |
416 KB |
Output is correct |
12 |
Correct |
327 ms |
748 KB |
Output is correct |
13 |
Correct |
411 ms |
628 KB |
Output is correct |
14 |
Correct |
348 ms |
556 KB |
Output is correct |
15 |
Correct |
35 ms |
496 KB |
Output is correct |
16 |
Correct |
47 ms |
564 KB |
Output is correct |
17 |
Correct |
91 ms |
500 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
618 ms |
420 KB |
Output is correct |
2 |
Correct |
460 ms |
416 KB |
Output is correct |
3 |
Correct |
435 ms |
500 KB |
Output is correct |
4 |
Correct |
1 ms |
500 KB |
Output is correct |
5 |
Correct |
3 ms |
488 KB |
Output is correct |
6 |
Correct |
0 ms |
492 KB |
Output is correct |
7 |
Correct |
545 ms |
508 KB |
Output is correct |
8 |
Correct |
651 ms |
420 KB |
Output is correct |
9 |
Correct |
668 ms |
416 KB |
Output is correct |
10 |
Correct |
539 ms |
504 KB |
Output is correct |
11 |
Correct |
4 ms |
492 KB |
Output is correct |
12 |
Correct |
3 ms |
492 KB |
Output is correct |
13 |
Correct |
3 ms |
496 KB |
Output is correct |
14 |
Correct |
2 ms |
488 KB |
Output is correct |
15 |
Correct |
1 ms |
492 KB |
Output is correct |
16 |
Correct |
407 ms |
504 KB |
Output is correct |
17 |
Correct |
503 ms |
420 KB |
Output is correct |
18 |
Correct |
359 ms |
544 KB |
Output is correct |
19 |
Correct |
341 ms |
480 KB |
Output is correct |
20 |
Correct |
437 ms |
416 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
501 ms |
752 KB |
Output is correct |
2 |
Correct |
402 ms |
544 KB |
Output is correct |
3 |
Correct |
670 ms |
504 KB |
Output is correct |
4 |
Correct |
605 ms |
500 KB |
Output is correct |
5 |
Correct |
470 ms |
496 KB |
Output is correct |
6 |
Correct |
348 ms |
620 KB |
Output is correct |
7 |
Correct |
407 ms |
480 KB |
Output is correct |
8 |
Correct |
1 ms |
500 KB |
Output is correct |
9 |
Correct |
3 ms |
492 KB |
Output is correct |
10 |
Correct |
1 ms |
492 KB |
Output is correct |
11 |
Correct |
370 ms |
500 KB |
Output is correct |
12 |
Correct |
380 ms |
496 KB |
Output is correct |
13 |
Correct |
773 ms |
416 KB |
Output is correct |
14 |
Correct |
542 ms |
508 KB |
Output is correct |
15 |
Correct |
542 ms |
416 KB |
Output is correct |
16 |
Correct |
331 ms |
544 KB |
Output is correct |
17 |
Correct |
526 ms |
508 KB |
Output is correct |
18 |
Correct |
413 ms |
696 KB |
Output is correct |
19 |
Correct |
431 ms |
720 KB |
Output is correct |
20 |
Correct |
280 ms |
544 KB |
Output is correct |
21 |
Correct |
41 ms |
452 KB |
Output is correct |
22 |
Correct |
58 ms |
620 KB |
Output is correct |
23 |
Correct |
76 ms |
596 KB |
Output is correct |
24 |
Correct |
3 ms |
492 KB |
Output is correct |
25 |
Correct |
4 ms |
492 KB |
Output is correct |
26 |
Correct |
3 ms |
492 KB |
Output is correct |
27 |
Correct |
4 ms |
500 KB |
Output is correct |
28 |
Correct |
2 ms |
492 KB |
Output is correct |
29 |
Correct |
414 ms |
504 KB |
Output is correct |
30 |
Correct |
465 ms |
424 KB |
Output is correct |
31 |
Correct |
455 ms |
504 KB |
Output is correct |
32 |
Correct |
364 ms |
420 KB |
Output is correct |
33 |
Correct |
334 ms |
420 KB |
Output is correct |
34 |
Correct |
251 ms |
672 KB |
Output is correct |
35 |
Correct |
295 ms |
704 KB |
Output is correct |
36 |
Correct |
419 ms |
752 KB |
Output is correct |
37 |
Correct |
332 ms |
740 KB |
Output is correct |
38 |
Correct |
319 ms |
700 KB |
Output is correct |
39 |
Correct |
354 ms |
632 KB |
Output is correct |
40 |
Correct |
459 ms |
720 KB |
Output is correct |
41 |
Correct |
339 ms |
708 KB |
Output is correct |
42 |
Correct |
41 ms |
536 KB |
Output is correct |
43 |
Correct |
85 ms |
568 KB |
Output is correct |
44 |
Correct |
87 ms |
596 KB |
Output is correct |
45 |
Correct |
142 ms |
504 KB |
Output is correct |
46 |
Correct |
282 ms |
588 KB |
Output is correct |
47 |
Correct |
210 ms |
548 KB |
Output is correct |
48 |
Correct |
52 ms |
604 KB |
Output is correct |
49 |
Correct |
46 ms |
740 KB |
Output is correct |