//#include "stations.h"
#include <vector>
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pi;
typedef vector <int> vi;
typedef vector <pi> vpi;
typedef pair<pi, ll> pii;
typedef set <ll> si;
typedef long double ld;
#define f first
#define s second
#define mp make_pair
#define FOR(i,s,e) for(int i=s;i<=int(e);++i)
#define DEC(i,s,e) for(int i=s;i>=int(e);--i)
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define lbd(x, y) lower_bound(all(x), y)
#define ubd(x, y) upper_bound(all(x), y)
#define aFOR(i,x) for (auto i: x)
#define mem(x,i) memset(x,i,sizeof x)
#define fast ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0)
#define maxn 200010
#define INF (ll)1e9
#define MOD 1000000007
typedef pair <vi, int> pvi;
typedef pair <int,pi> ipi;
typedef vector <pii> vpii;
vi labels;
int co = 0;
vi adj[maxn];
void dfs(int x,int p, bool f){
if (f) labels[x] = co++;
aFOR(i, adj[x]) if (i != p) dfs(i,x,!f);
if (!f) labels[x] = co++;
}
std::vector<int> label(int n, int k, std::vector<int> u, std::vector<int> v) {
FOR(i,0,n-1) adj[i].clear();
co = 0;
FOR(i,0,n-2){
adj[u[i]].pb(v[i]);
adj[v[i]].pb(u[i]);
}
labels = vi(n, 0);
dfs(0,-1,1);
/*
cout << "LABELS: ";
aFOR(i, labels) cout << i << ' ';
cout << '\n';
*/
return labels;
}
//#include "stations.h"
#include <vector>
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pi;
typedef vector <int> vi;
typedef vector <pi> vpi;
typedef pair<pi, ll> pii;
typedef set <ll> si;
typedef long double ld;
#define f first
#define s second
#define mp make_pair
#define FOR(i,s,e) for(int i=s;i<=int(e);++i)
#define DEC(i,s,e) for(int i=s;i>=int(e);--i)
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define lbd(x, y) lower_bound(all(x), y)
#define ubd(x, y) upper_bound(all(x), y)
#define aFOR(i,x) for (auto i: x)
#define mem(x,i) memset(x,i,sizeof x)
#define fast ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0)
#define maxn 200010
#define INF (ll)1e9
#define MOD 1000000007
typedef pair <vi, int> pvi;
typedef pair <int,pi> ipi;
typedef vector <pii> vpii;
int find_next_station(int s, int t, std::vector<int> c) {
bool pre = (c[0] > s);
if (c.size() == 1) return c[0];
if (pre){
int par = c.back(); c.pop_back();
if (s + 1 <= t && t <= c[0]) return c[0];
FOR(i,1,c.size()-1){
if (c[i-1] + 1 <= t && t <= c[i]) return c[i];
}
return par;
}else{
int par = c[0];
FOR(i,1,c.size()-2){
if (c[i] <= t && t <= c[i+1] - 1) return c[i];
}
if (c.back() <= t && t <= s - 1) return c.back();
return par;
}
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
530 ms |
10144 KB |
Output is correct |
2 |
Correct |
434 ms |
10020 KB |
Output is correct |
3 |
Correct |
779 ms |
9888 KB |
Output is correct |
4 |
Correct |
592 ms |
9892 KB |
Output is correct |
5 |
Correct |
575 ms |
9892 KB |
Output is correct |
6 |
Correct |
442 ms |
10008 KB |
Output is correct |
7 |
Correct |
442 ms |
9940 KB |
Output is correct |
8 |
Correct |
7 ms |
9936 KB |
Output is correct |
9 |
Correct |
8 ms |
9988 KB |
Output is correct |
10 |
Correct |
6 ms |
9976 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
473 ms |
9928 KB |
Output is correct |
2 |
Correct |
492 ms |
9924 KB |
Output is correct |
3 |
Correct |
806 ms |
9924 KB |
Output is correct |
4 |
Correct |
673 ms |
9892 KB |
Output is correct |
5 |
Correct |
527 ms |
9888 KB |
Output is correct |
6 |
Correct |
401 ms |
9932 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
480 ms |
10020 KB |
Output is correct |
2 |
Correct |
506 ms |
10060 KB |
Output is correct |
3 |
Correct |
763 ms |
9920 KB |
Output is correct |
4 |
Correct |
618 ms |
9948 KB |
Output is correct |
5 |
Correct |
568 ms |
9888 KB |
Output is correct |
6 |
Correct |
460 ms |
10056 KB |
Output is correct |
7 |
Correct |
438 ms |
10024 KB |
Output is correct |
8 |
Correct |
6 ms |
9984 KB |
Output is correct |
9 |
Correct |
8 ms |
9996 KB |
Output is correct |
10 |
Correct |
6 ms |
9980 KB |
Output is correct |
11 |
Correct |
600 ms |
9904 KB |
Output is correct |
12 |
Correct |
470 ms |
10072 KB |
Output is correct |
13 |
Correct |
451 ms |
10008 KB |
Output is correct |
14 |
Correct |
453 ms |
9920 KB |
Output is correct |
15 |
Correct |
59 ms |
9916 KB |
Output is correct |
16 |
Correct |
64 ms |
9888 KB |
Output is correct |
17 |
Correct |
113 ms |
10020 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
801 ms |
9892 KB |
Output is correct |
2 |
Correct |
686 ms |
9944 KB |
Output is correct |
3 |
Correct |
546 ms |
9868 KB |
Output is correct |
4 |
Correct |
6 ms |
9976 KB |
Output is correct |
5 |
Correct |
8 ms |
9976 KB |
Output is correct |
6 |
Correct |
6 ms |
9976 KB |
Output is correct |
7 |
Correct |
630 ms |
9944 KB |
Output is correct |
8 |
Correct |
748 ms |
9928 KB |
Output is correct |
9 |
Correct |
580 ms |
9888 KB |
Output is correct |
10 |
Correct |
538 ms |
10060 KB |
Output is correct |
11 |
Correct |
8 ms |
9976 KB |
Output is correct |
12 |
Correct |
8 ms |
9976 KB |
Output is correct |
13 |
Correct |
8 ms |
9976 KB |
Output is correct |
14 |
Correct |
8 ms |
9984 KB |
Output is correct |
15 |
Correct |
6 ms |
9984 KB |
Output is correct |
16 |
Correct |
480 ms |
9952 KB |
Output is correct |
17 |
Correct |
516 ms |
9888 KB |
Output is correct |
18 |
Correct |
513 ms |
9956 KB |
Output is correct |
19 |
Correct |
559 ms |
9964 KB |
Output is correct |
20 |
Correct |
500 ms |
9888 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
513 ms |
10036 KB |
Output is correct |
2 |
Correct |
488 ms |
10084 KB |
Output is correct |
3 |
Correct |
865 ms |
9896 KB |
Output is correct |
4 |
Correct |
674 ms |
9888 KB |
Output is correct |
5 |
Correct |
552 ms |
9932 KB |
Output is correct |
6 |
Correct |
469 ms |
10064 KB |
Output is correct |
7 |
Correct |
355 ms |
10020 KB |
Output is correct |
8 |
Correct |
7 ms |
9980 KB |
Output is correct |
9 |
Correct |
9 ms |
9992 KB |
Output is correct |
10 |
Correct |
6 ms |
9992 KB |
Output is correct |
11 |
Correct |
468 ms |
9892 KB |
Output is correct |
12 |
Correct |
423 ms |
9932 KB |
Output is correct |
13 |
Correct |
881 ms |
9936 KB |
Output is correct |
14 |
Correct |
623 ms |
9892 KB |
Output is correct |
15 |
Correct |
683 ms |
9888 KB |
Output is correct |
16 |
Correct |
392 ms |
9944 KB |
Output is correct |
17 |
Correct |
590 ms |
9944 KB |
Output is correct |
18 |
Correct |
410 ms |
9984 KB |
Output is correct |
19 |
Correct |
475 ms |
10020 KB |
Output is correct |
20 |
Correct |
428 ms |
9888 KB |
Output is correct |
21 |
Correct |
49 ms |
9956 KB |
Output is correct |
22 |
Correct |
64 ms |
9888 KB |
Output is correct |
23 |
Correct |
121 ms |
9916 KB |
Output is correct |
24 |
Correct |
7 ms |
10004 KB |
Output is correct |
25 |
Correct |
11 ms |
9968 KB |
Output is correct |
26 |
Correct |
10 ms |
9976 KB |
Output is correct |
27 |
Correct |
8 ms |
9976 KB |
Output is correct |
28 |
Correct |
6 ms |
9980 KB |
Output is correct |
29 |
Correct |
530 ms |
9944 KB |
Output is correct |
30 |
Correct |
510 ms |
9900 KB |
Output is correct |
31 |
Correct |
523 ms |
9944 KB |
Output is correct |
32 |
Correct |
505 ms |
9888 KB |
Output is correct |
33 |
Correct |
477 ms |
9888 KB |
Output is correct |
34 |
Correct |
327 ms |
9936 KB |
Output is correct |
35 |
Correct |
433 ms |
10116 KB |
Output is correct |
36 |
Correct |
459 ms |
10076 KB |
Output is correct |
37 |
Correct |
437 ms |
9968 KB |
Output is correct |
38 |
Correct |
508 ms |
9932 KB |
Output is correct |
39 |
Correct |
491 ms |
10040 KB |
Output is correct |
40 |
Correct |
423 ms |
10048 KB |
Output is correct |
41 |
Correct |
473 ms |
9976 KB |
Output is correct |
42 |
Correct |
60 ms |
9956 KB |
Output is correct |
43 |
Correct |
117 ms |
10020 KB |
Output is correct |
44 |
Correct |
126 ms |
10016 KB |
Output is correct |
45 |
Correct |
163 ms |
9940 KB |
Output is correct |
46 |
Correct |
292 ms |
10020 KB |
Output is correct |
47 |
Correct |
331 ms |
10016 KB |
Output is correct |
48 |
Correct |
63 ms |
10016 KB |
Output is correct |
49 |
Correct |
55 ms |
10052 KB |
Output is correct |