# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
1030212 | 2024-07-21T23:22:27 Z | Agreb | 가장 긴 여행 (IOI23_longesttrip) | C++17 | 867 ms | 692 KB |
#include <bits/stdc++.h> #include "longesttrip.h" using namespace std; vector <int> longest_trip(int N, int D){ vector <vector<int>> gr(N, vector<int>(N, 0)); vector <int> path; for (int i = 0; i < N; i++){ for (int j = 0; j < i; j++){ vector <int> a{i}, b{j}; gr[i][j] = gr[j][i] = are_connected(a, b); if (gr[i][j]){ path = {i, j}; } } } assert(!path.empty()); vector <int> on_path(N); for (int u : path) on_path[u] = 1; while (path.size() < N){ int P = path.size(); int st = path[0], fin = path[P-1]; int done = 0; for (int v = 0; v < N; v++){ if (!on_path[v]){ if (gr[st][v]){ reverse(path.begin(), path.end()); path.push_back(v); on_path[v] = 1; done = 1; break; } if (gr[fin][v]){ path.push_back(v); on_path[v] = 1; done = 1; break; } } } if (done) continue; assert(gr[st][fin] == 1); for (int v = 0; v < N; v++){ if (!on_path[v]){ for (int i = 0; i < P; i++){ if (gr[path[i]][v]){ vector <int> npath; for (int j = 0; j < P; j++) npath.push_back(path[(j+i+1)%P]); npath.push_back(v); path = npath; on_path[v] = 1; done = 1; break; } } if (done) break; } } if (done) continue; if (P >= N - P) return path; else{ vector <int> npath; for (int v = 0; v < N; v++){ if (!on_path[v]) npath.push_back(v); } return npath; } } return path; }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 344 KB | Output is correct |
2 | Correct | 206 ms | 600 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 5 ms | 344 KB | Output is correct |
2 | Correct | 27 ms | 344 KB | Output is correct |
3 | Correct | 149 ms | 344 KB | Output is correct |
4 | Correct | 417 ms | 480 KB | Output is correct |
5 | Correct | 730 ms | 600 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 6 ms | 344 KB | Output is correct |
2 | Correct | 26 ms | 344 KB | Output is correct |
3 | Correct | 170 ms | 344 KB | Output is correct |
4 | Correct | 388 ms | 500 KB | Output is correct |
5 | Correct | 854 ms | 600 KB | Output is correct |
6 | Correct | 8 ms | 344 KB | Output is correct |
7 | Correct | 20 ms | 340 KB | Output is correct |
8 | Correct | 144 ms | 344 KB | Output is correct |
9 | Correct | 299 ms | 344 KB | Output is correct |
10 | Correct | 833 ms | 600 KB | Output is correct |
11 | Correct | 823 ms | 600 KB | Output is correct |
12 | Correct | 867 ms | 600 KB | Output is correct |
13 | Correct | 787 ms | 600 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 8 ms | 344 KB | Output is correct |
2 | Correct | 21 ms | 344 KB | Output is correct |
3 | Correct | 142 ms | 344 KB | Output is correct |
4 | Correct | 373 ms | 344 KB | Output is correct |
5 | Correct | 718 ms | 600 KB | Output is correct |
6 | Correct | 7 ms | 344 KB | Output is correct |
7 | Correct | 21 ms | 344 KB | Output is correct |
8 | Correct | 135 ms | 344 KB | Output is correct |
9 | Correct | 301 ms | 344 KB | Output is correct |
10 | Correct | 834 ms | 600 KB | Output is correct |
11 | Correct | 783 ms | 600 KB | Output is correct |
12 | Correct | 754 ms | 600 KB | Output is correct |
13 | Correct | 765 ms | 600 KB | Output is correct |
14 | Correct | 7 ms | 344 KB | Output is correct |
15 | Correct | 11 ms | 344 KB | Output is correct |
16 | Correct | 40 ms | 344 KB | Output is correct |
17 | Correct | 83 ms | 344 KB | Output is correct |
18 | Correct | 133 ms | 344 KB | Output is correct |
19 | Correct | 295 ms | 344 KB | Output is correct |
20 | Correct | 286 ms | 344 KB | Output is correct |
21 | Correct | 762 ms | 600 KB | Output is correct |
22 | Correct | 783 ms | 600 KB | Output is correct |
23 | Correct | 777 ms | 676 KB | Output is correct |
24 | Correct | 826 ms | 600 KB | Output is correct |
25 | Correct | 8 ms | 344 KB | Output is correct |
26 | Correct | 5 ms | 344 KB | Output is correct |
27 | Correct | 27 ms | 420 KB | Output is correct |
28 | Correct | 24 ms | 340 KB | Output is correct |
29 | Correct | 15 ms | 344 KB | Output is correct |
30 | Correct | 177 ms | 344 KB | Output is correct |
31 | Correct | 189 ms | 344 KB | Output is correct |
32 | Correct | 188 ms | 344 KB | Output is correct |
33 | Correct | 270 ms | 344 KB | Output is correct |
34 | Correct | 276 ms | 344 KB | Output is correct |
35 | Correct | 301 ms | 340 KB | Output is correct |
36 | Correct | 799 ms | 600 KB | Output is correct |
37 | Correct | 727 ms | 600 KB | Output is correct |
38 | Correct | 773 ms | 600 KB | Output is correct |
39 | Correct | 765 ms | 600 KB | Output is correct |
40 | Correct | 769 ms | 600 KB | Output is correct |
41 | Correct | 736 ms | 600 KB | Output is correct |
42 | Correct | 730 ms | 600 KB | Output is correct |
43 | Correct | 705 ms | 600 KB | Output is correct |
44 | Correct | 714 ms | 600 KB | Output is correct |
45 | Correct | 7 ms | 344 KB | Output is correct |
46 | Correct | 8 ms | 344 KB | Output is correct |
47 | Correct | 23 ms | 344 KB | Output is correct |
48 | Correct | 18 ms | 344 KB | Output is correct |
49 | Correct | 17 ms | 344 KB | Output is correct |
50 | Correct | 163 ms | 344 KB | Output is correct |
51 | Correct | 172 ms | 344 KB | Output is correct |
52 | Correct | 157 ms | 344 KB | Output is correct |
53 | Correct | 259 ms | 344 KB | Output is correct |
54 | Correct | 239 ms | 344 KB | Output is correct |
55 | Correct | 264 ms | 344 KB | Output is correct |
56 | Correct | 668 ms | 600 KB | Output is correct |
57 | Correct | 755 ms | 684 KB | Output is correct |
58 | Correct | 713 ms | 684 KB | Output is correct |
59 | Correct | 717 ms | 676 KB | Output is correct |
60 | Correct | 747 ms | 676 KB | Output is correct |
61 | Correct | 704 ms | 600 KB | Output is correct |
62 | Correct | 778 ms | 600 KB | Output is correct |
63 | Correct | 762 ms | 684 KB | Output is correct |
64 | Correct | 780 ms | 600 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 9 ms | 344 KB | Output is correct |
2 | Correct | 17 ms | 344 KB | Output is correct |
3 | Partially correct | 146 ms | 344 KB | Output is partially correct |
4 | Partially correct | 370 ms | 592 KB | Output is partially correct |
5 | Partially correct | 787 ms | 600 KB | Output is partially correct |
6 | Correct | 7 ms | 596 KB | Output is correct |
7 | Correct | 23 ms | 344 KB | Output is correct |
8 | Partially correct | 141 ms | 344 KB | Output is partially correct |
9 | Partially correct | 293 ms | 344 KB | Output is partially correct |
10 | Partially correct | 847 ms | 600 KB | Output is partially correct |
11 | Partially correct | 841 ms | 600 KB | Output is partially correct |
12 | Partially correct | 841 ms | 600 KB | Output is partially correct |
13 | Partially correct | 802 ms | 600 KB | Output is partially correct |
14 | Correct | 7 ms | 344 KB | Output is correct |
15 | Correct | 11 ms | 344 KB | Output is correct |
16 | Correct | 39 ms | 344 KB | Output is correct |
17 | Partially correct | 112 ms | 344 KB | Output is partially correct |
18 | Partially correct | 180 ms | 344 KB | Output is partially correct |
19 | Partially correct | 296 ms | 344 KB | Output is partially correct |
20 | Partially correct | 294 ms | 344 KB | Output is partially correct |
21 | Correct | 10 ms | 344 KB | Output is correct |
22 | Correct | 9 ms | 344 KB | Output is correct |
23 | Correct | 29 ms | 344 KB | Output is correct |
24 | Correct | 16 ms | 344 KB | Output is correct |
25 | Correct | 29 ms | 344 KB | Output is correct |
26 | Partially correct | 190 ms | 344 KB | Output is partially correct |
27 | Partially correct | 165 ms | 344 KB | Output is partially correct |
28 | Partially correct | 159 ms | 344 KB | Output is partially correct |
29 | Partially correct | 292 ms | 344 KB | Output is partially correct |
30 | Partially correct | 301 ms | 344 KB | Output is partially correct |
31 | Partially correct | 249 ms | 344 KB | Output is partially correct |
32 | Correct | 7 ms | 344 KB | Output is correct |
33 | Correct | 7 ms | 344 KB | Output is correct |
34 | Correct | 18 ms | 344 KB | Output is correct |
35 | Correct | 13 ms | 344 KB | Output is correct |
36 | Correct | 26 ms | 344 KB | Output is correct |
37 | Partially correct | 146 ms | 344 KB | Output is partially correct |
38 | Partially correct | 162 ms | 344 KB | Output is partially correct |
39 | Partially correct | 178 ms | 596 KB | Output is partially correct |
40 | Partially correct | 261 ms | 596 KB | Output is partially correct |
41 | Partially correct | 237 ms | 344 KB | Output is partially correct |
42 | Partially correct | 253 ms | 344 KB | Output is partially correct |
43 | Partially correct | 752 ms | 600 KB | Output is partially correct |
44 | Partially correct | 699 ms | 600 KB | Output is partially correct |
45 | Partially correct | 736 ms | 676 KB | Output is partially correct |
46 | Partially correct | 711 ms | 600 KB | Output is partially correct |
47 | Partially correct | 737 ms | 600 KB | Output is partially correct |
48 | Partially correct | 778 ms | 600 KB | Output is partially correct |
49 | Partially correct | 701 ms | 600 KB | Output is partially correct |
50 | Partially correct | 703 ms | 600 KB | Output is partially correct |
51 | Partially correct | 757 ms | 600 KB | Output is partially correct |
52 | Partially correct | 701 ms | 600 KB | Output is partially correct |
53 | Partially correct | 706 ms | 600 KB | Output is partially correct |
54 | Partially correct | 724 ms | 600 KB | Output is partially correct |
55 | Partially correct | 708 ms | 600 KB | Output is partially correct |
56 | Partially correct | 742 ms | 600 KB | Output is partially correct |
57 | Partially correct | 803 ms | 596 KB | Output is partially correct |
58 | Partially correct | 820 ms | 600 KB | Output is partially correct |
59 | Partially correct | 797 ms | 600 KB | Output is partially correct |
60 | Partially correct | 813 ms | 600 KB | Output is partially correct |
61 | Partially correct | 805 ms | 596 KB | Output is partially correct |
62 | Partially correct | 796 ms | 680 KB | Output is partially correct |
63 | Partially correct | 788 ms | 676 KB | Output is partially correct |
64 | Partially correct | 842 ms | 684 KB | Output is partially correct |
65 | Partially correct | 759 ms | 692 KB | Output is partially correct |
66 | Partially correct | 817 ms | 684 KB | Output is partially correct |
67 | Partially correct | 754 ms | 600 KB | Output is partially correct |
68 | Partially correct | 790 ms | 600 KB | Output is partially correct |
69 | Partially correct | 693 ms | 680 KB | Output is partially correct |
70 | Partially correct | 714 ms | 600 KB | Output is partially correct |
71 | Partially correct | 726 ms | 680 KB | Output is partially correct |
72 | Partially correct | 786 ms | 676 KB | Output is partially correct |
73 | Partially correct | 714 ms | 600 KB | Output is partially correct |
74 | Partially correct | 716 ms | 600 KB | Output is partially correct |
75 | Partially correct | 713 ms | 600 KB | Output is partially correct |
76 | Partially correct | 682 ms | 600 KB | Output is partially correct |
77 | Partially correct | 696 ms | 684 KB | Output is partially correct |
78 | Partially correct | 703 ms | 688 KB | Output is partially correct |
79 | Partially correct | 710 ms | 680 KB | Output is partially correct |
80 | Partially correct | 673 ms | 684 KB | Output is partially correct |
81 | Partially correct | 676 ms | 600 KB | Output is partially correct |
82 | Partially correct | 737 ms | 600 KB | Output is partially correct |