답안 #696355

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
696355 2023-02-06T09:43:50 Z esomer 기지국 (IOI20_stations) C++17
100 / 100
899 ms 720 KB
#include<bits/stdc++.h>
 
using namespace std;
 
#define endl "\n"
 
typedef long long int ll;

const int MOD = 1e9 + 7;

vector<int> ans;
int cnt;

void DFS(int x, vector<vector<int>>& adj, int p, int d){
	if(d%2 == 0) {ans[x] = cnt; cnt++;}
	for(int node : adj[x]){
		if(node != p) DFS(node, adj, x, d + 1);
	}
	if(d%2 == 1){ans[x] = cnt; cnt++;}
}

vector<int> label(int n, int k, vector<int> u, vector<int> v){
	vector<vector<int>> adj(n);
	cnt = 0;
	ans.resize(n);
	for(int i = 0; i < n - 1; i++){
		adj[u[i]].push_back(v[i]);
		adj[v[i]].push_back(u[i]);
	}
	DFS(0, adj, -1, 0);
	return ans;
}

int find_next_station(int s, int t, vector<int> c){
	bool st = 1;
	if(s > c[0]) st = 0;
	int n = (int)c.size();
	int start = s;
	for(int i = 0; i < n; i++){
		if(st == 0 && i == 0) continue;
		else if(st == 1 && i == n - 1) continue;
		if(st == 1){
			if(t > start && t <= c[i]){
				return c[i];
			}else start = c[i];
		}else{
			if(i == n - 1){
				if(t >= c[i] && t < s) return c[i];
			}else{
				if(t >= c[i] && t < c[i + 1]){
					return c[i];
				}
			}
		}
	}
	if(st == 0) return c[0];
	else return c[n - 1];
}
# 결과 실행 시간 메모리 Grader output
1 Correct 508 ms 632 KB Output is correct
2 Correct 431 ms 628 KB Output is correct
3 Correct 872 ms 420 KB Output is correct
4 Correct 510 ms 484 KB Output is correct
5 Correct 507 ms 420 KB Output is correct
6 Correct 376 ms 612 KB Output is correct
7 Correct 381 ms 620 KB Output is correct
8 Correct 2 ms 500 KB Output is correct
9 Correct 2 ms 492 KB Output is correct
10 Correct 0 ms 500 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 450 ms 508 KB Output is correct
2 Correct 507 ms 500 KB Output is correct
3 Correct 709 ms 420 KB Output is correct
4 Correct 542 ms 508 KB Output is correct
5 Correct 576 ms 416 KB Output is correct
6 Correct 420 ms 548 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 478 ms 536 KB Output is correct
2 Correct 440 ms 640 KB Output is correct
3 Correct 776 ms 504 KB Output is correct
4 Correct 671 ms 504 KB Output is correct
5 Correct 560 ms 420 KB Output is correct
6 Correct 463 ms 620 KB Output is correct
7 Correct 392 ms 544 KB Output is correct
8 Correct 2 ms 492 KB Output is correct
9 Correct 4 ms 500 KB Output is correct
10 Correct 1 ms 500 KB Output is correct
11 Correct 518 ms 420 KB Output is correct
12 Correct 428 ms 624 KB Output is correct
13 Correct 479 ms 704 KB Output is correct
14 Correct 491 ms 480 KB Output is correct
15 Correct 49 ms 500 KB Output is correct
16 Correct 66 ms 560 KB Output is correct
17 Correct 113 ms 544 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 864 ms 520 KB Output is correct
2 Correct 619 ms 420 KB Output is correct
3 Correct 481 ms 504 KB Output is correct
4 Correct 2 ms 500 KB Output is correct
5 Correct 4 ms 492 KB Output is correct
6 Correct 1 ms 500 KB Output is correct
7 Correct 530 ms 416 KB Output is correct
8 Correct 899 ms 548 KB Output is correct
9 Correct 618 ms 508 KB Output is correct
10 Correct 531 ms 504 KB Output is correct
11 Correct 4 ms 492 KB Output is correct
12 Correct 4 ms 492 KB Output is correct
13 Correct 3 ms 492 KB Output is correct
14 Correct 4 ms 492 KB Output is correct
15 Correct 1 ms 488 KB Output is correct
16 Correct 409 ms 496 KB Output is correct
17 Correct 472 ms 508 KB Output is correct
18 Correct 470 ms 504 KB Output is correct
19 Correct 360 ms 508 KB Output is correct
20 Correct 490 ms 504 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 558 ms 628 KB Output is correct
2 Correct 412 ms 632 KB Output is correct
3 Correct 801 ms 420 KB Output is correct
4 Correct 575 ms 416 KB Output is correct
5 Correct 576 ms 508 KB Output is correct
6 Correct 356 ms 620 KB Output is correct
7 Correct 409 ms 548 KB Output is correct
8 Correct 2 ms 500 KB Output is correct
9 Correct 4 ms 492 KB Output is correct
10 Correct 1 ms 500 KB Output is correct
11 Correct 440 ms 508 KB Output is correct
12 Correct 490 ms 504 KB Output is correct
13 Correct 788 ms 488 KB Output is correct
14 Correct 589 ms 544 KB Output is correct
15 Correct 585 ms 420 KB Output is correct
16 Correct 414 ms 544 KB Output is correct
17 Correct 441 ms 416 KB Output is correct
18 Correct 399 ms 700 KB Output is correct
19 Correct 363 ms 692 KB Output is correct
20 Correct 390 ms 548 KB Output is correct
21 Correct 47 ms 492 KB Output is correct
22 Correct 70 ms 512 KB Output is correct
23 Correct 95 ms 548 KB Output is correct
24 Correct 5 ms 492 KB Output is correct
25 Correct 6 ms 584 KB Output is correct
26 Correct 5 ms 504 KB Output is correct
27 Correct 2 ms 500 KB Output is correct
28 Correct 1 ms 500 KB Output is correct
29 Correct 534 ms 504 KB Output is correct
30 Correct 479 ms 508 KB Output is correct
31 Correct 502 ms 512 KB Output is correct
32 Correct 496 ms 504 KB Output is correct
33 Correct 488 ms 420 KB Output is correct
34 Correct 296 ms 636 KB Output is correct
35 Correct 426 ms 692 KB Output is correct
36 Correct 426 ms 712 KB Output is correct
37 Correct 454 ms 616 KB Output is correct
38 Correct 489 ms 672 KB Output is correct
39 Correct 451 ms 632 KB Output is correct
40 Correct 368 ms 620 KB Output is correct
41 Correct 463 ms 720 KB Output is correct
42 Correct 59 ms 536 KB Output is correct
43 Correct 90 ms 548 KB Output is correct
44 Correct 132 ms 508 KB Output is correct
45 Correct 145 ms 512 KB Output is correct
46 Correct 308 ms 492 KB Output is correct
47 Correct 303 ms 548 KB Output is correct
48 Correct 48 ms 672 KB Output is correct
49 Correct 49 ms 668 KB Output is correct