답안 #1074668

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1074668 2024-08-25T11:59:57 Z pan 기지국 (IOI20_stations) C++17
100 / 100
641 ms 1196 KB
#include <bits/stdc++.h>
//#include "bits_stdc++.h"
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
#define endl '\n'
#define f first
#define s second
#define pb push_back
#define mp make_pair
#define lb lower_bound
#define ub upper_bound
#define input(x) scanf("%lld", &x);
#define input2(x, y) scanf("%lld%lld", &x, &y);
#define input3(x, y, z) scanf("%lld%lld%lld", &x, &y, &z);
#define input4(x, y, z, a) scanf("%lld%lld%lld%lld", &x, &y, &z, &a);
#define print(x, y) printf("%lld%c", x, y);
#define show(x) cerr << #x << " is " << x << endl;
#define show2(x,y) cerr << #x << " is " << x << " " << #y << " is " << y << endl;
#define show3(x,y,z) cerr << #x << " is " << x << " " << #y << " is " << y << " " << #z << " is " << z << endl;
#define all(x) x.begin(), x.end()
#define discretize(x) sort(x.begin(), x.end()); x.erase(unique(x.begin(), x.end()), x.end());
#define FOR(i, x, n) for (ll i =x; i<=n; ++i) 
#define RFOR(i, x, n) for (ll i =x; i>=n; --i) 
using namespace std;
mt19937 rng(chrono::system_clock::now().time_since_epoch().count());
//using namespace __gnu_pbds;
//#define ordered_set tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>
//#define ordered_multiset tree<int, null_type, less_equal<int>, rb_tree_tag, tree_order_statistics_node_update>
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<ld, ll> pd;
typedef pair<string, ll> psl;
typedef pair<ll, ll> pi;
typedef pair<pi, ll> pii;
typedef pair<pi, pi> piii;

vector<vector<ll> > adj;
vector<ll> m;
ll stfu;
vector<int> in;

void dfs(ll x, ll p = -1)
{
	if (m[x]) in[x] = ++stfu;
	for (ll u: adj[x]) if (u!=p) {m[u] = !m[x]; dfs(u, x);}
	if (!m[x]) in[x] = ++stfu;
}

std::vector<int> label(int n, int k, std::vector<int> u, std::vector<int> v)
{
	adj.clear();
	adj.resize(n);
	m.resize(n);
	in.assign(n, 0);
	for (ll i=0; i<n-1; ++i)
	{
		adj[u[i]].pb(v[i]);
		adj[v[i]].pb(u[i]);
	}
	stfu = -1;
	m[0] = 0;
	dfs(0);
	return in;
	
}
int find_next_station(int s, int t, std::vector<int> c)
{
	if (s < c[0]) // case 1: post-pre-post
	{
		if (t >= c.back() || t < s) return c.back();
		return *lb(all(c), t);
	}
	else // case 2: pre-post-pre
	{
		if (t > s || t <= c[0] ) return c[0];
		return *prev(ub(all(c), t));
	}
}
# 결과 실행 시간 메모리 Grader output
1 Correct 364 ms 684 KB Output is correct
2 Correct 296 ms 684 KB Output is correct
3 Correct 635 ms 684 KB Output is correct
4 Correct 478 ms 684 KB Output is correct
5 Correct 408 ms 684 KB Output is correct
6 Correct 309 ms 696 KB Output is correct
7 Correct 305 ms 684 KB Output is correct
8 Correct 2 ms 1016 KB Output is correct
9 Correct 1 ms 768 KB Output is correct
10 Correct 0 ms 768 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 315 ms 684 KB Output is correct
2 Correct 310 ms 684 KB Output is correct
3 Correct 634 ms 684 KB Output is correct
4 Correct 445 ms 684 KB Output is correct
5 Correct 407 ms 684 KB Output is correct
6 Correct 300 ms 684 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 374 ms 940 KB Output is correct
2 Correct 337 ms 684 KB Output is correct
3 Correct 620 ms 684 KB Output is correct
4 Correct 482 ms 684 KB Output is correct
5 Correct 391 ms 684 KB Output is correct
6 Correct 289 ms 684 KB Output is correct
7 Correct 306 ms 684 KB Output is correct
8 Correct 2 ms 764 KB Output is correct
9 Correct 1 ms 768 KB Output is correct
10 Correct 1 ms 768 KB Output is correct
11 Correct 389 ms 772 KB Output is correct
12 Correct 325 ms 932 KB Output is correct
13 Correct 303 ms 764 KB Output is correct
14 Correct 299 ms 684 KB Output is correct
15 Correct 31 ms 768 KB Output is correct
16 Correct 35 ms 772 KB Output is correct
17 Correct 60 ms 768 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 611 ms 684 KB Output is correct
2 Correct 478 ms 684 KB Output is correct
3 Correct 428 ms 684 KB Output is correct
4 Correct 2 ms 768 KB Output is correct
5 Correct 4 ms 764 KB Output is correct
6 Correct 1 ms 776 KB Output is correct
7 Correct 440 ms 684 KB Output is correct
8 Correct 641 ms 684 KB Output is correct
9 Correct 470 ms 684 KB Output is correct
10 Correct 372 ms 684 KB Output is correct
11 Correct 3 ms 776 KB Output is correct
12 Correct 2 ms 768 KB Output is correct
13 Correct 2 ms 768 KB Output is correct
14 Correct 1 ms 768 KB Output is correct
15 Correct 1 ms 768 KB Output is correct
16 Correct 329 ms 684 KB Output is correct
17 Correct 368 ms 684 KB Output is correct
18 Correct 363 ms 684 KB Output is correct
19 Correct 355 ms 684 KB Output is correct
20 Correct 350 ms 688 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 363 ms 1196 KB Output is correct
2 Correct 326 ms 684 KB Output is correct
3 Correct 601 ms 684 KB Output is correct
4 Correct 449 ms 684 KB Output is correct
5 Correct 415 ms 684 KB Output is correct
6 Correct 300 ms 680 KB Output is correct
7 Correct 357 ms 684 KB Output is correct
8 Correct 2 ms 764 KB Output is correct
9 Correct 1 ms 768 KB Output is correct
10 Correct 0 ms 768 KB Output is correct
11 Correct 286 ms 684 KB Output is correct
12 Correct 347 ms 684 KB Output is correct
13 Correct 633 ms 684 KB Output is correct
14 Correct 457 ms 684 KB Output is correct
15 Correct 420 ms 684 KB Output is correct
16 Correct 278 ms 684 KB Output is correct
17 Correct 405 ms 684 KB Output is correct
18 Correct 332 ms 768 KB Output is correct
19 Correct 313 ms 684 KB Output is correct
20 Correct 300 ms 684 KB Output is correct
21 Correct 27 ms 684 KB Output is correct
22 Correct 38 ms 764 KB Output is correct
23 Correct 56 ms 764 KB Output is correct
24 Correct 3 ms 772 KB Output is correct
25 Correct 3 ms 768 KB Output is correct
26 Correct 3 ms 768 KB Output is correct
27 Correct 2 ms 768 KB Output is correct
28 Correct 0 ms 768 KB Output is correct
29 Correct 368 ms 772 KB Output is correct
30 Correct 373 ms 684 KB Output is correct
31 Correct 350 ms 684 KB Output is correct
32 Correct 321 ms 684 KB Output is correct
33 Correct 343 ms 684 KB Output is correct
34 Correct 214 ms 684 KB Output is correct
35 Correct 297 ms 940 KB Output is correct
36 Correct 296 ms 1196 KB Output is correct
37 Correct 306 ms 1028 KB Output is correct
38 Correct 284 ms 940 KB Output is correct
39 Correct 308 ms 780 KB Output is correct
40 Correct 308 ms 932 KB Output is correct
41 Correct 304 ms 776 KB Output is correct
42 Correct 35 ms 684 KB Output is correct
43 Correct 64 ms 716 KB Output is correct
44 Correct 69 ms 716 KB Output is correct
45 Correct 104 ms 684 KB Output is correct
46 Correct 198 ms 684 KB Output is correct
47 Correct 222 ms 712 KB Output is correct
48 Correct 28 ms 740 KB Output is correct
49 Correct 27 ms 820 KB Output is correct