답안 #1062597

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1062597 2024-08-17T08:58:53 Z jamjanek 기지국 (IOI20_stations) C++14
52.3205 / 100
614 ms 1164 KB
#include "stations.h"
#include <bits/stdc++.h>
using namespace std;

vector<int>graf[1010];
int pre[1010], it=-1, post[1010];
void dfs(int x, int o){
	pre[x] = ++it;
	for(auto j: graf[x])
		if(j!=o)
			dfs(j, x);
	post[x] = it;
}
vector<int> label(int n, int k, std::vector<int> u, std::vector<int> v) {
	int i;
	for(i=0;i<n;i++)graf[i].clear();
	for(i=0;i<n-1;i++){
		graf[u[i]].push_back(v[i]);
		graf[v[i]].push_back(u[i]);
	}
	it= -1;
	dfs(0, 0);
	std::vector<int> labels(n);
	for (int i = 0; i < n; i++) {
		labels[i] = 1000*pre[i]+post[i];
	}
	return labels;
}

int find_next_station(int s, int t, std::vector<int> c) {
	int pre1, post1, pre2, post2;
	pre1 = s/1000;post1 = s%1000;
	pre2 = t/1000;post2 = t%1000;
	int ojciec;
	for(auto j: c){
		int pre3 = j/1000, post3 = j%1000;
		if(pre3<pre1){
			ojciec = j;
			continue;
		}
		if(pre3<=pre2 && pre2<=post3)
			return j;
	}
	return ojciec;
}

Compilation message

stations.cpp: In function 'int find_next_station(int, int, std::vector<int>)':
stations.cpp:31:12: warning: variable 'post1' set but not used [-Wunused-but-set-variable]
   31 |  int pre1, post1, pre2, post2;
      |            ^~~~~
stations.cpp:31:25: warning: variable 'post2' set but not used [-Wunused-but-set-variable]
   31 |  int pre1, post1, pre2, post2;
      |                         ^~~~~
stations.cpp:34:6: warning: 'ojciec' may be used uninitialized in this function [-Wmaybe-uninitialized]
   34 |  int ojciec;
      |      ^~~~~~
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 344 KB Invalid labels (values out of range). scenario=0, k=1000, vertex=1, label=6009
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 344 KB Invalid labels (values out of range). scenario=0, k=1000, vertex=1, label=1511
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 358 ms 684 KB Output is correct
2 Correct 305 ms 684 KB Output is correct
3 Correct 591 ms 684 KB Output is correct
4 Correct 452 ms 684 KB Output is correct
5 Correct 383 ms 684 KB Output is correct
6 Correct 311 ms 684 KB Output is correct
7 Correct 306 ms 688 KB Output is correct
8 Correct 1 ms 768 KB Output is correct
9 Correct 3 ms 768 KB Output is correct
10 Correct 1 ms 768 KB Output is correct
11 Correct 407 ms 684 KB Output is correct
12 Correct 364 ms 800 KB Output is correct
13 Correct 330 ms 784 KB Output is correct
14 Correct 304 ms 684 KB Output is correct
15 Correct 36 ms 768 KB Output is correct
16 Correct 28 ms 768 KB Output is correct
17 Correct 64 ms 684 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 576 ms 684 KB Output is correct
2 Correct 375 ms 684 KB Output is correct
3 Correct 370 ms 684 KB Output is correct
4 Correct 2 ms 768 KB Output is correct
5 Correct 1 ms 768 KB Output is correct
6 Correct 1 ms 768 KB Output is correct
7 Correct 385 ms 688 KB Output is correct
8 Correct 463 ms 684 KB Output is correct
9 Correct 345 ms 692 KB Output is correct
10 Correct 334 ms 684 KB Output is correct
11 Correct 4 ms 768 KB Output is correct
12 Correct 3 ms 768 KB Output is correct
13 Correct 2 ms 776 KB Output is correct
14 Correct 1 ms 792 KB Output is correct
15 Correct 0 ms 792 KB Output is correct
16 Correct 287 ms 684 KB Output is correct
17 Correct 329 ms 800 KB Output is correct
18 Correct 301 ms 684 KB Output is correct
19 Correct 244 ms 796 KB Output is correct
20 Correct 295 ms 684 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Partially correct 326 ms 684 KB Partially correct
2 Partially correct 298 ms 684 KB Partially correct
3 Partially correct 546 ms 684 KB Partially correct
4 Partially correct 393 ms 684 KB Partially correct
5 Partially correct 324 ms 796 KB Partially correct
6 Partially correct 282 ms 800 KB Partially correct
7 Partially correct 291 ms 684 KB Partially correct
8 Partially correct 1 ms 768 KB Partially correct
9 Partially correct 3 ms 768 KB Partially correct
10 Partially correct 1 ms 768 KB Partially correct
11 Partially correct 301 ms 684 KB Partially correct
12 Partially correct 331 ms 684 KB Partially correct
13 Partially correct 614 ms 936 KB Partially correct
14 Partially correct 478 ms 684 KB Partially correct
15 Partially correct 352 ms 684 KB Partially correct
16 Partially correct 310 ms 796 KB Partially correct
17 Partially correct 401 ms 680 KB Partially correct
18 Partially correct 306 ms 796 KB Partially correct
19 Partially correct 327 ms 1004 KB Partially correct
20 Partially correct 300 ms 696 KB Partially correct
21 Partially correct 38 ms 692 KB Partially correct
22 Partially correct 38 ms 768 KB Partially correct
23 Partially correct 67 ms 688 KB Partially correct
24 Partially correct 3 ms 776 KB Partially correct
25 Partially correct 3 ms 776 KB Partially correct
26 Partially correct 3 ms 768 KB Partially correct
27 Partially correct 1 ms 768 KB Partially correct
28 Partially correct 1 ms 776 KB Partially correct
29 Partially correct 335 ms 684 KB Partially correct
30 Partially correct 349 ms 684 KB Partially correct
31 Partially correct 347 ms 684 KB Partially correct
32 Partially correct 348 ms 684 KB Partially correct
33 Partially correct 355 ms 684 KB Partially correct
34 Partially correct 198 ms 884 KB Partially correct
35 Partially correct 278 ms 924 KB Partially correct
36 Partially correct 268 ms 1164 KB Partially correct
37 Partially correct 351 ms 792 KB Partially correct
38 Partially correct 328 ms 932 KB Partially correct
39 Partially correct 313 ms 800 KB Partially correct
40 Partially correct 302 ms 796 KB Partially correct
41 Partially correct 311 ms 1144 KB Partially correct
42 Partially correct 37 ms 704 KB Partially correct
43 Partially correct 67 ms 1024 KB Partially correct
44 Partially correct 77 ms 684 KB Partially correct
45 Partially correct 105 ms 848 KB Partially correct
46 Partially correct 217 ms 684 KB Partially correct
47 Partially correct 182 ms 684 KB Partially correct
48 Partially correct 36 ms 844 KB Partially correct
49 Partially correct 30 ms 1124 KB Partially correct