답안 #757658

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
757658 2023-06-13T14:12:48 Z 1bin 기지국 (IOI20_stations) C++14
100 / 100
956 ms 824 KB
#include <bits/stdc++.h>
#include "stations.h"

using namespace std;

#define all(v) v.begin(), v.end()
typedef long long ll;
const int NMAX = 1005;
int t, L[NMAX];
vector<int> adj[NMAX];

void dfs(int x, int p, int f){
    if(!f) L[x] = t++;
    for(int&nx : adj[x])
        if(nx != p) dfs(nx, x, !f);
    if(f) L[x] = t++;
    return;
}

vector<int>label(int n, int k, vector<int> u, vector<int> v) {
	vector<int> labels(n);
	for(int i = 0; i < n - 1; i++){
	    adj[u[i]].emplace_back(v[i]);
	    adj[v[i]].emplace_back(u[i]);
	}
    
    t = 0;	
	dfs(0, -1, 0);
	for(int i = 0; i < n; i++) {
	    labels[i] = L[i];
	    adj[i].clear();
	}
	return labels;
}

int find_next_station(int s, int t, vector<int> c) {
    int sz = c.size();
    if(s < c[0]){
        for(int i = 0; i < sz; i++){
            int l = !i ? s : c[i - 1] + 1, r = c[i];
            if(t >= l && t <= r) return c[i];
        }
        return c.back();
    }
    else{
        for(int i = 1; i < sz; i++){
            int l = c[i], r = (i == sz - 1 ? s - 1: c[i + 1] - 1);
            if(t >= l && t <= r) return c[i];
        }
        return c[0];
    }
}
# 결과 실행 시간 메모리 Grader output
1 Correct 522 ms 540 KB Output is correct
2 Correct 515 ms 532 KB Output is correct
3 Correct 743 ms 416 KB Output is correct
4 Correct 727 ms 416 KB Output is correct
5 Correct 602 ms 416 KB Output is correct
6 Correct 410 ms 528 KB Output is correct
7 Correct 481 ms 528 KB Output is correct
8 Correct 3 ms 492 KB Output is correct
9 Correct 4 ms 500 KB Output is correct
10 Correct 1 ms 492 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 506 ms 740 KB Output is correct
2 Correct 591 ms 544 KB Output is correct
3 Correct 741 ms 420 KB Output is correct
4 Correct 688 ms 532 KB Output is correct
5 Correct 548 ms 524 KB Output is correct
6 Correct 520 ms 544 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 615 ms 568 KB Output is correct
2 Correct 479 ms 520 KB Output is correct
3 Correct 915 ms 416 KB Output is correct
4 Correct 618 ms 420 KB Output is correct
5 Correct 528 ms 524 KB Output is correct
6 Correct 477 ms 568 KB Output is correct
7 Correct 442 ms 548 KB Output is correct
8 Correct 2 ms 492 KB Output is correct
9 Correct 5 ms 500 KB Output is correct
10 Correct 2 ms 492 KB Output is correct
11 Correct 562 ms 516 KB Output is correct
12 Correct 498 ms 652 KB Output is correct
13 Correct 500 ms 648 KB Output is correct
14 Correct 500 ms 544 KB Output is correct
15 Correct 55 ms 620 KB Output is correct
16 Correct 80 ms 608 KB Output is correct
17 Correct 91 ms 528 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 824 ms 528 KB Output is correct
2 Correct 644 ms 420 KB Output is correct
3 Correct 542 ms 416 KB Output is correct
4 Correct 3 ms 500 KB Output is correct
5 Correct 3 ms 500 KB Output is correct
6 Correct 2 ms 492 KB Output is correct
7 Correct 665 ms 528 KB Output is correct
8 Correct 956 ms 416 KB Output is correct
9 Correct 622 ms 528 KB Output is correct
10 Correct 564 ms 524 KB Output is correct
11 Correct 6 ms 604 KB Output is correct
12 Correct 6 ms 492 KB Output is correct
13 Correct 6 ms 492 KB Output is correct
14 Correct 4 ms 500 KB Output is correct
15 Correct 1 ms 500 KB Output is correct
16 Correct 416 ms 420 KB Output is correct
17 Correct 476 ms 524 KB Output is correct
18 Correct 435 ms 528 KB Output is correct
19 Correct 409 ms 544 KB Output is correct
20 Correct 493 ms 528 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 492 ms 544 KB Output is correct
2 Correct 395 ms 548 KB Output is correct
3 Correct 738 ms 416 KB Output is correct
4 Correct 626 ms 528 KB Output is correct
5 Correct 607 ms 416 KB Output is correct
6 Correct 490 ms 544 KB Output is correct
7 Correct 460 ms 548 KB Output is correct
8 Correct 3 ms 500 KB Output is correct
9 Correct 3 ms 500 KB Output is correct
10 Correct 2 ms 492 KB Output is correct
11 Correct 406 ms 540 KB Output is correct
12 Correct 484 ms 548 KB Output is correct
13 Correct 731 ms 532 KB Output is correct
14 Correct 629 ms 420 KB Output is correct
15 Correct 470 ms 524 KB Output is correct
16 Correct 383 ms 548 KB Output is correct
17 Correct 618 ms 528 KB Output is correct
18 Correct 418 ms 544 KB Output is correct
19 Correct 483 ms 676 KB Output is correct
20 Correct 462 ms 548 KB Output is correct
21 Correct 47 ms 492 KB Output is correct
22 Correct 69 ms 704 KB Output is correct
23 Correct 77 ms 672 KB Output is correct
24 Correct 5 ms 492 KB Output is correct
25 Correct 5 ms 492 KB Output is correct
26 Correct 4 ms 488 KB Output is correct
27 Correct 3 ms 472 KB Output is correct
28 Correct 1 ms 488 KB Output is correct
29 Correct 431 ms 528 KB Output is correct
30 Correct 430 ms 532 KB Output is correct
31 Correct 518 ms 524 KB Output is correct
32 Correct 498 ms 420 KB Output is correct
33 Correct 562 ms 536 KB Output is correct
34 Correct 292 ms 532 KB Output is correct
35 Correct 357 ms 668 KB Output is correct
36 Correct 511 ms 548 KB Output is correct
37 Correct 466 ms 548 KB Output is correct
38 Correct 455 ms 660 KB Output is correct
39 Correct 411 ms 656 KB Output is correct
40 Correct 480 ms 664 KB Output is correct
41 Correct 454 ms 644 KB Output is correct
42 Correct 66 ms 676 KB Output is correct
43 Correct 94 ms 788 KB Output is correct
44 Correct 157 ms 572 KB Output is correct
45 Correct 131 ms 604 KB Output is correct
46 Correct 263 ms 532 KB Output is correct
47 Correct 266 ms 528 KB Output is correct
48 Correct 56 ms 704 KB Output is correct
49 Correct 55 ms 824 KB Output is correct