답안 #738518

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
738518 2023-05-09T01:53:40 Z bobthebuilder 기지국 (IOI20_stations) C++17
100 / 100
1043 ms 10236 KB
#include "stations.h"
#include<bits/stdc++.h>
using namespace std;
#define sz(x) (int)x.size()
#define REP(i,n) for(int i=0;i<n;i++)
#define REP1(i,n) for(int i=1;i<=n;i++)
#define pb push_back
#define lowb(x) (x&(-x))
#define ALL(_x) _x.begin(),_x.end()
#define pii pair<int,int>
#define f first
#define s second
#define SORT_UNIQUE(x) sort(ALL(x)),x.erase(unique(ALL(x)),x.end())
#define ll long long
#define MNTO(x,y) x=min(x,y)
#define MXTO(x,y) x=max(x,y)
const int maxn=2e5+5;
const int INF=0x3f3f3f3f;
int dep[maxn];
vector<int> g[maxn];
int in[maxn],out[maxn];
int cur=0;
void dfs(int u,int p){
	in[u]=(cur++);
	for(int x:g[u]){
		if(x==p) continue;
		dep[x]=dep[u]+1;
		dfs(x,u);
	}
	out[u]=cur-1;
}
std::vector<int> label(int n, int k, std::vector<int> u, std::vector<int> v) {
	cur=0;
	REP(i,n) g[i].clear();
	REP(i,n-1){
		g[u[i]].pb(v[i]),g[v[i]].pb(u[i]);
	}
	dfs(0,-1);
	vector<pair<pii,int>> ans;
	REP(i,n){
		if(dep[i]%2) ans.pb({{in[i],-dep[i]},i});
		else ans.pb({{out[i],-dep[i]},i});
	}
	vector<int> vv(n,0);
	sort(ALL(ans));
	REP(i,n){
		vv[ans[i].s]=i;
	}
	return vv;
}

int find_next_station(int s, int t, std::vector<int> c) {
	if(s<c[0]){
		c.emplace(c.begin(),s);
		//s labeled in 
		REP1(i,sz(c)-1){
			if(t<=c[i] and t>c[i-1]){
				return c[i];
			}
		}
		return c.back();
	}
	else{
		c.pb(s);
		REP1(i,sz(c)-2){
			if(t>=c[i] and t<c[i+1]){
				return c[i];
			}
		}
		return c[0];
	}
}
# 결과 실행 시간 메모리 Grader output
1 Correct 560 ms 10068 KB Output is correct
2 Correct 487 ms 10020 KB Output is correct
3 Correct 1043 ms 9944 KB Output is correct
4 Correct 644 ms 9944 KB Output is correct
5 Correct 575 ms 9892 KB Output is correct
6 Correct 514 ms 10064 KB Output is correct
7 Correct 535 ms 10060 KB Output is correct
8 Correct 8 ms 9980 KB Output is correct
9 Correct 7 ms 9988 KB Output is correct
10 Correct 6 ms 9980 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 501 ms 9940 KB Output is correct
2 Correct 588 ms 9944 KB Output is correct
3 Correct 831 ms 10008 KB Output is correct
4 Correct 696 ms 9936 KB Output is correct
5 Correct 592 ms 9888 KB Output is correct
6 Correct 492 ms 10020 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 561 ms 10016 KB Output is correct
2 Correct 448 ms 10012 KB Output is correct
3 Correct 820 ms 9892 KB Output is correct
4 Correct 765 ms 9948 KB Output is correct
5 Correct 631 ms 9868 KB Output is correct
6 Correct 459 ms 10016 KB Output is correct
7 Correct 436 ms 10068 KB Output is correct
8 Correct 6 ms 9980 KB Output is correct
9 Correct 9 ms 9980 KB Output is correct
10 Correct 5 ms 9988 KB Output is correct
11 Correct 638 ms 9928 KB Output is correct
12 Correct 527 ms 10236 KB Output is correct
13 Correct 434 ms 10060 KB Output is correct
14 Correct 485 ms 10016 KB Output is correct
15 Correct 49 ms 9980 KB Output is correct
16 Correct 70 ms 10060 KB Output is correct
17 Correct 89 ms 10016 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 902 ms 9944 KB Output is correct
2 Correct 660 ms 9892 KB Output is correct
3 Correct 586 ms 9948 KB Output is correct
4 Correct 6 ms 9960 KB Output is correct
5 Correct 8 ms 9980 KB Output is correct
6 Correct 5 ms 9980 KB Output is correct
7 Correct 599 ms 9892 KB Output is correct
8 Correct 920 ms 9904 KB Output is correct
9 Correct 723 ms 9892 KB Output is correct
10 Correct 611 ms 10012 KB Output is correct
11 Correct 8 ms 9980 KB Output is correct
12 Correct 8 ms 9928 KB Output is correct
13 Correct 8 ms 9984 KB Output is correct
14 Correct 6 ms 9988 KB Output is correct
15 Correct 6 ms 9988 KB Output is correct
16 Correct 512 ms 9940 KB Output is correct
17 Correct 529 ms 10016 KB Output is correct
18 Correct 502 ms 9888 KB Output is correct
19 Correct 462 ms 9892 KB Output is correct
20 Correct 445 ms 10016 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 508 ms 10072 KB Output is correct
2 Correct 409 ms 10016 KB Output is correct
3 Correct 834 ms 9940 KB Output is correct
4 Correct 717 ms 10016 KB Output is correct
5 Correct 659 ms 10016 KB Output is correct
6 Correct 429 ms 10016 KB Output is correct
7 Correct 496 ms 10020 KB Output is correct
8 Correct 7 ms 9988 KB Output is correct
9 Correct 9 ms 9900 KB Output is correct
10 Correct 5 ms 9980 KB Output is correct
11 Correct 519 ms 9944 KB Output is correct
12 Correct 562 ms 10016 KB Output is correct
13 Correct 913 ms 9920 KB Output is correct
14 Correct 719 ms 9892 KB Output is correct
15 Correct 648 ms 9964 KB Output is correct
16 Correct 458 ms 10020 KB Output is correct
17 Correct 614 ms 9892 KB Output is correct
18 Correct 406 ms 9992 KB Output is correct
19 Correct 518 ms 10068 KB Output is correct
20 Correct 446 ms 10016 KB Output is correct
21 Correct 66 ms 9892 KB Output is correct
22 Correct 82 ms 10044 KB Output is correct
23 Correct 90 ms 10044 KB Output is correct
24 Correct 9 ms 9980 KB Output is correct
25 Correct 10 ms 10016 KB Output is correct
26 Correct 9 ms 9980 KB Output is correct
27 Correct 7 ms 9988 KB Output is correct
28 Correct 6 ms 9964 KB Output is correct
29 Correct 509 ms 10020 KB Output is correct
30 Correct 543 ms 9888 KB Output is correct
31 Correct 526 ms 9892 KB Output is correct
32 Correct 550 ms 9944 KB Output is correct
33 Correct 542 ms 10020 KB Output is correct
34 Correct 321 ms 10016 KB Output is correct
35 Correct 450 ms 10088 KB Output is correct
36 Correct 476 ms 10072 KB Output is correct
37 Correct 499 ms 10196 KB Output is correct
38 Correct 453 ms 10072 KB Output is correct
39 Correct 499 ms 10184 KB Output is correct
40 Correct 451 ms 10200 KB Output is correct
41 Correct 451 ms 10084 KB Output is correct
42 Correct 61 ms 10016 KB Output is correct
43 Correct 122 ms 9940 KB Output is correct
44 Correct 106 ms 10044 KB Output is correct
45 Correct 152 ms 10016 KB Output is correct
46 Correct 333 ms 10020 KB Output is correct
47 Correct 322 ms 10016 KB Output is correct
48 Correct 55 ms 10164 KB Output is correct
49 Correct 49 ms 10044 KB Output is correct