답안 #433043

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
433043 2021-06-18T18:51:56 Z peuch 기지국 (IOI20_stations) C++17
69.868 / 100
964 ms 832 KB
#include "stations.h"
#include <bits/stdc++.h>
using namespace std;

int cnt;
vector<vector<int> > ar;
vector<int> lbl;

void dfs(int cur, int pai, int prof){
	if(prof % 2 == 0) lbl[cur] = cnt++;
	for(int i = 0; i < ar[cur].size(); i++){
		int viz = ar[cur][i];
		if(viz == pai) continue;
		dfs(viz, cur, prof + 1);
	}
	if(prof % 2 == 1) lbl[cur] = cnt++;
}

vector<int> label(int n, int k, vector<int> u, vector<int> v) {
	ar = vector<vector<int> > (n);
	lbl = vector<int> (n);
	for(int i = 0; i < u.size(); i++){
		ar[u[i]].push_back(v[i]);
		ar[v[i]].push_back(u[i]);
	}
	dfs(0, 0, 0);
	return lbl;
}

int find_next_station(int s, int t, std::vector<int> c) {
	if(t == s) return s;
	if(c.size() == 1) return c[0];
	if(s < c[0]){
		if(t < s) return c.back();
		for(int i = 0; i < c.size(); i++)
			if(t <= c[i]) return c[i];
		return c.back();
	}
	else{
		if(t > s) return c[0];
		for(int i = c.size() - 1; i >= 0; i--)
			if(t >= c[i]) return c[i];
		return c[0];
	}
}

Compilation message

stations.cpp: In function 'void dfs(int, int, int)':
stations.cpp:11:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   11 |  for(int i = 0; i < ar[cur].size(); i++){
      |                 ~~^~~~~~~~~~~~~~~~
stations.cpp: In function 'std::vector<int> label(int, int, std::vector<int>, std::vector<int>)':
stations.cpp:22:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   22 |  for(int i = 0; i < u.size(); i++){
      |                 ~~^~~~~~~~~~
stations.cpp: In function 'int find_next_station(int, int, std::vector<int>)':
stations.cpp:35:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   35 |   for(int i = 0; i < c.size(); i++)
      |                  ~~^~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Incorrect 3 ms 408 KB Invalid labels (values out of range). scenario=2, k=1000, vertex=1, label=1008
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 7 ms 424 KB Invalid labels (values out of range). scenario=1, k=1000, vertex=1, label=1507
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 551 ms 656 KB Output is correct
2 Correct 453 ms 656 KB Output is correct
3 Correct 839 ms 400 KB Output is correct
4 Correct 642 ms 528 KB Output is correct
5 Correct 644 ms 400 KB Output is correct
6 Correct 454 ms 616 KB Output is correct
7 Correct 408 ms 528 KB Output is correct
8 Correct 3 ms 468 KB Output is correct
9 Correct 4 ms 468 KB Output is correct
10 Correct 2 ms 476 KB Output is correct
11 Correct 587 ms 400 KB Output is correct
12 Correct 422 ms 692 KB Output is correct
13 Correct 479 ms 728 KB Output is correct
14 Correct 475 ms 480 KB Output is correct
15 Correct 56 ms 400 KB Output is correct
16 Correct 57 ms 528 KB Output is correct
17 Correct 94 ms 624 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 933 ms 464 KB Output is correct
2 Correct 704 ms 400 KB Output is correct
3 Correct 667 ms 488 KB Output is correct
4 Correct 3 ms 400 KB Output is correct
5 Correct 6 ms 400 KB Output is correct
6 Correct 2 ms 468 KB Output is correct
7 Correct 699 ms 556 KB Output is correct
8 Correct 964 ms 488 KB Output is correct
9 Correct 661 ms 488 KB Output is correct
10 Correct 577 ms 492 KB Output is correct
11 Correct 6 ms 400 KB Output is correct
12 Correct 5 ms 468 KB Output is correct
13 Correct 4 ms 448 KB Output is correct
14 Correct 3 ms 468 KB Output is correct
15 Correct 2 ms 464 KB Output is correct
16 Correct 514 ms 488 KB Output is correct
17 Correct 485 ms 400 KB Output is correct
18 Correct 457 ms 492 KB Output is correct
19 Correct 483 ms 400 KB Output is correct
20 Correct 473 ms 400 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Partially correct 554 ms 648 KB Partially correct
2 Partially correct 412 ms 620 KB Partially correct
3 Correct 845 ms 472 KB Output is correct
4 Correct 626 ms 400 KB Output is correct
5 Correct 659 ms 528 KB Output is correct
6 Partially correct 497 ms 608 KB Partially correct
7 Correct 365 ms 476 KB Output is correct
8 Correct 3 ms 468 KB Output is correct
9 Correct 4 ms 468 KB Output is correct
10 Correct 2 ms 468 KB Output is correct
11 Partially correct 444 ms 592 KB Partially correct
12 Partially correct 510 ms 484 KB Partially correct
13 Correct 882 ms 400 KB Output is correct
14 Correct 649 ms 488 KB Output is correct
15 Correct 600 ms 480 KB Output is correct
16 Correct 428 ms 528 KB Output is correct
17 Correct 552 ms 400 KB Output is correct
18 Partially correct 465 ms 688 KB Partially correct
19 Partially correct 448 ms 688 KB Partially correct
20 Correct 466 ms 488 KB Output is correct
21 Correct 54 ms 448 KB Output is correct
22 Partially correct 86 ms 536 KB Partially correct
23 Partially correct 112 ms 488 KB Partially correct
24 Correct 4 ms 468 KB Output is correct
25 Correct 5 ms 468 KB Output is correct
26 Correct 5 ms 448 KB Output is correct
27 Correct 5 ms 420 KB Output is correct
28 Correct 2 ms 420 KB Output is correct
29 Correct 492 ms 400 KB Output is correct
30 Correct 524 ms 460 KB Output is correct
31 Correct 551 ms 484 KB Output is correct
32 Correct 581 ms 456 KB Output is correct
33 Correct 533 ms 488 KB Output is correct
34 Partially correct 311 ms 680 KB Partially correct
35 Partially correct 524 ms 628 KB Partially correct
36 Partially correct 451 ms 692 KB Partially correct
37 Partially correct 544 ms 692 KB Partially correct
38 Partially correct 485 ms 692 KB Partially correct
39 Partially correct 402 ms 728 KB Partially correct
40 Partially correct 441 ms 684 KB Partially correct
41 Partially correct 439 ms 832 KB Partially correct
42 Partially correct 65 ms 640 KB Partially correct
43 Partially correct 133 ms 604 KB Partially correct
44 Partially correct 143 ms 656 KB Partially correct
45 Partially correct 170 ms 620 KB Partially correct
46 Partially correct 312 ms 576 KB Partially correct
47 Partially correct 338 ms 688 KB Partially correct
48 Partially correct 74 ms 632 KB Partially correct
49 Partially correct 62 ms 648 KB Partially correct