답안 #985465

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
985465 2024-05-17T21:36:25 Z Seb 기지국 (IOI20_stations) C++17
100 / 100
643 ms 1644 KB
#include "stations.h"
#include <bits/stdc++.h>

using namespace std;

void dfs(int nodo, int p, vector<vector<int>> &g, vector <int> &labels, int caso, int &t) {
    if (caso == 0) labels[nodo] = t++;
    for (auto &it : g[nodo]) {
        if (it == p) continue;
        dfs(it, nodo, g, labels, (caso^1), t);
    }
    if (caso == 1) labels[nodo] = t++;
    return;
}

std::vector<int> label(int n, int k, std::vector<int> u, std::vector<int> v) {
	std::vector<int> labels(n);
	vector<vector<int>> g(n);
	for (int i = 0; i < n - 1; i++) {
        g[u[i]].push_back(v[i]);
        g[v[i]].push_back(u[i]);
	}
	int t = 0;
	dfs(0, 0, g, labels, 0, t);
	return labels;
}

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

Compilation message

stations.cpp: In function 'int find_next_station(int, int, std::vector<int>)':
stations.cpp:38:27: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   38 |         for (int i = 0; i < c.size(); i++)
      |                         ~~^~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 328 ms 932 KB Output is correct
2 Correct 269 ms 940 KB Output is correct
3 Correct 554 ms 688 KB Output is correct
4 Correct 488 ms 684 KB Output is correct
5 Correct 412 ms 684 KB Output is correct
6 Correct 294 ms 916 KB Output is correct
7 Correct 280 ms 684 KB Output is correct
8 Correct 2 ms 764 KB Output is correct
9 Correct 3 ms 768 KB Output is correct
10 Correct 0 ms 768 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 303 ms 856 KB Output is correct
2 Correct 332 ms 796 KB Output is correct
3 Correct 603 ms 684 KB Output is correct
4 Correct 422 ms 936 KB Output is correct
5 Correct 388 ms 684 KB Output is correct
6 Correct 265 ms 684 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 332 ms 944 KB Output is correct
2 Correct 281 ms 944 KB Output is correct
3 Correct 572 ms 684 KB Output is correct
4 Correct 435 ms 684 KB Output is correct
5 Correct 414 ms 684 KB Output is correct
6 Correct 281 ms 916 KB Output is correct
7 Correct 286 ms 684 KB Output is correct
8 Correct 2 ms 1016 KB Output is correct
9 Correct 3 ms 768 KB Output is correct
10 Correct 0 ms 768 KB Output is correct
11 Correct 388 ms 684 KB Output is correct
12 Correct 303 ms 940 KB Output is correct
13 Correct 298 ms 1456 KB Output is correct
14 Correct 270 ms 684 KB Output is correct
15 Correct 38 ms 768 KB Output is correct
16 Correct 35 ms 908 KB Output is correct
17 Correct 58 ms 1144 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 557 ms 940 KB Output is correct
2 Correct 412 ms 684 KB Output is correct
3 Correct 369 ms 684 KB Output is correct
4 Correct 2 ms 768 KB Output is correct
5 Correct 3 ms 768 KB Output is correct
6 Correct 1 ms 764 KB Output is correct
7 Correct 416 ms 772 KB Output is correct
8 Correct 546 ms 684 KB Output is correct
9 Correct 482 ms 688 KB Output is correct
10 Correct 395 ms 684 KB Output is correct
11 Correct 4 ms 768 KB Output is correct
12 Correct 4 ms 768 KB Output is correct
13 Correct 2 ms 768 KB Output is correct
14 Correct 2 ms 768 KB Output is correct
15 Correct 1 ms 768 KB Output is correct
16 Correct 340 ms 684 KB Output is correct
17 Correct 350 ms 684 KB Output is correct
18 Correct 321 ms 944 KB Output is correct
19 Correct 332 ms 944 KB Output is correct
20 Correct 307 ms 684 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 337 ms 928 KB Output is correct
2 Correct 287 ms 928 KB Output is correct
3 Correct 643 ms 684 KB Output is correct
4 Correct 450 ms 684 KB Output is correct
5 Correct 386 ms 684 KB Output is correct
6 Correct 288 ms 944 KB Output is correct
7 Correct 275 ms 684 KB Output is correct
8 Correct 1 ms 768 KB Output is correct
9 Correct 2 ms 768 KB Output is correct
10 Correct 0 ms 768 KB Output is correct
11 Correct 292 ms 848 KB Output is correct
12 Correct 341 ms 824 KB Output is correct
13 Correct 566 ms 684 KB Output is correct
14 Correct 490 ms 684 KB Output is correct
15 Correct 373 ms 684 KB Output is correct
16 Correct 293 ms 940 KB Output is correct
17 Correct 370 ms 684 KB Output is correct
18 Correct 276 ms 1160 KB Output is correct
19 Correct 273 ms 1272 KB Output is correct
20 Correct 283 ms 684 KB Output is correct
21 Correct 30 ms 768 KB Output is correct
22 Correct 35 ms 884 KB Output is correct
23 Correct 56 ms 936 KB Output is correct
24 Correct 4 ms 764 KB Output is correct
25 Correct 3 ms 768 KB Output is correct
26 Correct 2 ms 768 KB Output is correct
27 Correct 2 ms 768 KB Output is correct
28 Correct 1 ms 768 KB Output is correct
29 Correct 344 ms 684 KB Output is correct
30 Correct 333 ms 684 KB Output is correct
31 Correct 306 ms 944 KB Output is correct
32 Correct 305 ms 684 KB Output is correct
33 Correct 354 ms 684 KB Output is correct
34 Correct 196 ms 900 KB Output is correct
35 Correct 302 ms 1136 KB Output is correct
36 Correct 320 ms 1176 KB Output is correct
37 Correct 268 ms 1112 KB Output is correct
38 Correct 274 ms 1124 KB Output is correct
39 Correct 296 ms 1124 KB Output is correct
40 Correct 278 ms 960 KB Output is correct
41 Correct 287 ms 1128 KB Output is correct
42 Correct 36 ms 912 KB Output is correct
43 Correct 68 ms 932 KB Output is correct
44 Correct 89 ms 852 KB Output is correct
45 Correct 116 ms 904 KB Output is correct
46 Correct 196 ms 856 KB Output is correct
47 Correct 206 ms 900 KB Output is correct
48 Correct 35 ms 1212 KB Output is correct
49 Correct 36 ms 1644 KB Output is correct