# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
895406 | 2023-12-29T21:40:07 Z | vjudge1 | 가장 긴 여행 (IOI23_longesttrip) | C++17 | 810 ms | 2244 KB |
#include "longesttrip.h" #include <vector> #include <cstdio> #include <algorithm> using namespace std; // <|°_°|> const int MAX_NODES = 256; bool Edge[MAX_NODES][MAX_NODES]; vector <int> Adj[MAX_NODES]; vector <int> Path; int Seen[MAX_NODES]; int Dfs(int node) { if (Seen[node]) return 0; Path.push_back(node); int ans = Seen[node] = 1; for (int dest : Adj[node]) ans += Dfs(dest); return ans; } vector <int> longest_trip(int nbNodes, int density) { for (int i = 0; i < nbNodes; i ++) { Adj[i].clear(); fill_n(Edge[i], nbNodes, 0); } Path.clear(); fill_n(Seen, nbNodes, 0); for (int i = 0; i < nbNodes; i ++) { for (int j = i + 1; j < nbNodes; j ++) { if (are_connected({i}, {j})) { Edge[i][j] = Edge[j][i] = 1; Adj[i].push_back(j); Adj[j].push_back(i); } } } int n = Dfs(0); if (n != nbNodes) { int first = (2 * n) >= nbNodes; vector <int> v; for (int i = 0; i < nbNodes; i ++) { if (Seen[i] == first) v.push_back(i); } return v; } vector <int> v = {0}; for (int a : Path) { if (!a) continue; if (Edge[v.back()][a]) v.push_back(a); else if (Edge[v[0]][a]) { reverse(v.begin(), v.end()); v.push_back(a); } else { vector <int> nv; while (!Edge[a][v.back()]) { nv.push_back(v.back()); v.pop_back(); } v.push_back(a); reverse(v.begin(), v.end()); for (int a : nv) v.push_back(a); } } return v; }
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 344 KB | Output is correct |
2 | Correct | 183 ms | 1656 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 6 ms | 344 KB | Output is correct |
2 | Correct | 24 ms | 344 KB | Output is correct |
3 | Correct | 110 ms | 856 KB | Output is correct |
4 | Correct | 348 ms | 1008 KB | Output is correct |
5 | Correct | 700 ms | 1368 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 7 ms | 344 KB | Output is correct |
2 | Correct | 24 ms | 344 KB | Output is correct |
3 | Correct | 133 ms | 868 KB | Output is correct |
4 | Correct | 321 ms | 1488 KB | Output is correct |
5 | Correct | 686 ms | 1196 KB | Output is correct |
6 | Correct | 7 ms | 340 KB | Output is correct |
7 | Correct | 25 ms | 344 KB | Output is correct |
8 | Correct | 115 ms | 1112 KB | Output is correct |
9 | Correct | 242 ms | 992 KB | Output is correct |
10 | Correct | 799 ms | 1692 KB | Output is correct |
11 | Correct | 710 ms | 1320 KB | Output is correct |
12 | Correct | 705 ms | 1400 KB | Output is correct |
13 | Correct | 660 ms | 1620 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 9 ms | 344 KB | Output is correct |
2 | Correct | 22 ms | 344 KB | Output is correct |
3 | Correct | 111 ms | 600 KB | Output is correct |
4 | Correct | 341 ms | 1104 KB | Output is correct |
5 | Correct | 687 ms | 1188 KB | Output is correct |
6 | Correct | 6 ms | 344 KB | Output is correct |
7 | Correct | 18 ms | 344 KB | Output is correct |
8 | Correct | 114 ms | 600 KB | Output is correct |
9 | Correct | 226 ms | 968 KB | Output is correct |
10 | Correct | 706 ms | 1616 KB | Output is correct |
11 | Correct | 689 ms | 1188 KB | Output is correct |
12 | Correct | 686 ms | 1368 KB | Output is correct |
13 | Correct | 677 ms | 1620 KB | Output is correct |
14 | Correct | 7 ms | 344 KB | Output is correct |
15 | Correct | 10 ms | 344 KB | Output is correct |
16 | Correct | 36 ms | 344 KB | Output is correct |
17 | Correct | 63 ms | 600 KB | Output is correct |
18 | Correct | 121 ms | 856 KB | Output is correct |
19 | Correct | 226 ms | 892 KB | Output is correct |
20 | Correct | 261 ms | 1748 KB | Output is correct |
21 | Correct | 681 ms | 1920 KB | Output is correct |
22 | Correct | 668 ms | 1444 KB | Output is correct |
23 | Correct | 694 ms | 1988 KB | Output is correct |
24 | Correct | 679 ms | 2152 KB | Output is correct |
25 | Correct | 8 ms | 344 KB | Output is correct |
26 | Correct | 8 ms | 344 KB | Output is correct |
27 | Correct | 21 ms | 344 KB | Output is correct |
28 | Correct | 19 ms | 344 KB | Output is correct |
29 | Correct | 23 ms | 344 KB | Output is correct |
30 | Correct | 157 ms | 968 KB | Output is correct |
31 | Correct | 144 ms | 964 KB | Output is correct |
32 | Correct | 148 ms | 712 KB | Output is correct |
33 | Correct | 240 ms | 640 KB | Output is correct |
34 | Correct | 245 ms | 1112 KB | Output is correct |
35 | Correct | 248 ms | 856 KB | Output is correct |
36 | Correct | 746 ms | 1680 KB | Output is correct |
37 | Correct | 709 ms | 1360 KB | Output is correct |
38 | Correct | 720 ms | 1508 KB | Output is correct |
39 | Correct | 706 ms | 1556 KB | Output is correct |
40 | Correct | 686 ms | 1800 KB | Output is correct |
41 | Correct | 748 ms | 1368 KB | Output is correct |
42 | Correct | 702 ms | 1076 KB | Output is correct |
43 | Correct | 728 ms | 1572 KB | Output is correct |
44 | Correct | 763 ms | 1436 KB | Output is correct |
45 | Correct | 8 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 | 24 ms | 344 KB | Output is correct |
49 | Correct | 21 ms | 344 KB | Output is correct |
50 | Correct | 167 ms | 1220 KB | Output is correct |
51 | Correct | 145 ms | 1224 KB | Output is correct |
52 | Correct | 185 ms | 712 KB | Output is correct |
53 | Correct | 235 ms | 600 KB | Output is correct |
54 | Correct | 282 ms | 1112 KB | Output is correct |
55 | Correct | 287 ms | 756 KB | Output is correct |
56 | Correct | 688 ms | 1296 KB | Output is correct |
57 | Correct | 712 ms | 1316 KB | Output is correct |
58 | Correct | 760 ms | 1596 KB | Output is correct |
59 | Correct | 680 ms | 1828 KB | Output is correct |
60 | Correct | 717 ms | 1540 KB | Output is correct |
61 | Correct | 746 ms | 1280 KB | Output is correct |
62 | Correct | 761 ms | 1312 KB | Output is correct |
63 | Correct | 682 ms | 1232 KB | Output is correct |
64 | Correct | 764 ms | 1708 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 6 ms | 344 KB | Output is correct |
2 | Correct | 27 ms | 344 KB | Output is correct |
3 | Partially correct | 115 ms | 1112 KB | Output is partially correct |
4 | Partially correct | 360 ms | 1004 KB | Output is partially correct |
5 | Partially correct | 696 ms | 1836 KB | Output is partially correct |
6 | Correct | 6 ms | 344 KB | Output is correct |
7 | Correct | 20 ms | 344 KB | Output is correct |
8 | Partially correct | 113 ms | 856 KB | Output is partially correct |
9 | Partially correct | 242 ms | 1360 KB | Output is partially correct |
10 | Partially correct | 780 ms | 1588 KB | Output is partially correct |
11 | Partially correct | 701 ms | 1364 KB | Output is partially correct |
12 | Partially correct | 709 ms | 1556 KB | Output is partially correct |
13 | Partially correct | 794 ms | 1548 KB | Output is partially correct |
14 | Correct | 7 ms | 344 KB | Output is correct |
15 | Correct | 10 ms | 344 KB | Output is correct |
16 | Correct | 41 ms | 344 KB | Output is correct |
17 | Partially correct | 68 ms | 600 KB | Output is partially correct |
18 | Partially correct | 114 ms | 600 KB | Output is partially correct |
19 | Partially correct | 254 ms | 968 KB | Output is partially correct |
20 | Partially correct | 252 ms | 992 KB | Output is partially correct |
21 | Correct | 7 ms | 344 KB | Output is correct |
22 | Correct | 9 ms | 344 KB | Output is correct |
23 | Correct | 18 ms | 344 KB | Output is correct |
24 | Correct | 21 ms | 344 KB | Output is correct |
25 | Correct | 19 ms | 344 KB | Output is correct |
26 | Partially correct | 148 ms | 956 KB | Output is partially correct |
27 | Partially correct | 148 ms | 960 KB | Output is partially correct |
28 | Partially correct | 182 ms | 712 KB | Output is partially correct |
29 | Partially correct | 239 ms | 976 KB | Output is partially correct |
30 | Partially correct | 241 ms | 1132 KB | Output is partially correct |
31 | Partially correct | 269 ms | 856 KB | Output is partially correct |
32 | Correct | 7 ms | 344 KB | Output is correct |
33 | Correct | 9 ms | 344 KB | Output is correct |
34 | Correct | 20 ms | 344 KB | Output is correct |
35 | Correct | 21 ms | 344 KB | Output is correct |
36 | Correct | 23 ms | 344 KB | Output is correct |
37 | Partially correct | 158 ms | 1216 KB | Output is partially correct |
38 | Partially correct | 159 ms | 964 KB | Output is partially correct |
39 | Partially correct | 177 ms | 708 KB | Output is partially correct |
40 | Partially correct | 235 ms | 600 KB | Output is partially correct |
41 | Partially correct | 278 ms | 1136 KB | Output is partially correct |
42 | Partially correct | 224 ms | 1104 KB | Output is partially correct |
43 | Partially correct | 721 ms | 1360 KB | Output is partially correct |
44 | Partially correct | 712 ms | 1868 KB | Output is partially correct |
45 | Partially correct | 723 ms | 1940 KB | Output is partially correct |
46 | Partially correct | 714 ms | 1720 KB | Output is partially correct |
47 | Partially correct | 749 ms | 1432 KB | Output is partially correct |
48 | Partially correct | 728 ms | 1560 KB | Output is partially correct |
49 | Partially correct | 741 ms | 1812 KB | Output is partially correct |
50 | Partially correct | 808 ms | 2244 KB | Output is partially correct |
51 | Partially correct | 703 ms | 1872 KB | Output is partially correct |
52 | Partially correct | 696 ms | 1820 KB | Output is partially correct |
53 | Partially correct | 779 ms | 1120 KB | Output is partially correct |
54 | Partially correct | 714 ms | 1412 KB | Output is partially correct |
55 | Partially correct | 769 ms | 1380 KB | Output is partially correct |
56 | Partially correct | 783 ms | 1776 KB | Output is partially correct |
57 | Partially correct | 702 ms | 1504 KB | Output is partially correct |
58 | Partially correct | 704 ms | 1624 KB | Output is partially correct |
59 | Partially correct | 658 ms | 1892 KB | Output is partially correct |
60 | Partially correct | 700 ms | 1572 KB | Output is partially correct |
61 | Partially correct | 723 ms | 1588 KB | Output is partially correct |
62 | Partially correct | 743 ms | 1656 KB | Output is partially correct |
63 | Partially correct | 769 ms | 1684 KB | Output is partially correct |
64 | Partially correct | 688 ms | 1140 KB | Output is partially correct |
65 | Partially correct | 680 ms | 1800 KB | Output is partially correct |
66 | Partially correct | 810 ms | 1812 KB | Output is partially correct |
67 | Partially correct | 724 ms | 1612 KB | Output is partially correct |
68 | Partially correct | 706 ms | 1084 KB | Output is partially correct |
69 | Partially correct | 713 ms | 1584 KB | Output is partially correct |
70 | Partially correct | 747 ms | 1748 KB | Output is partially correct |
71 | Partially correct | 753 ms | 1584 KB | Output is partially correct |
72 | Partially correct | 672 ms | 1592 KB | Output is partially correct |
73 | Partially correct | 721 ms | 1984 KB | Output is partially correct |
74 | Partially correct | 694 ms | 1616 KB | Output is partially correct |
75 | Partially correct | 713 ms | 944 KB | Output is partially correct |
76 | Partially correct | 750 ms | 1028 KB | Output is partially correct |
77 | Partially correct | 716 ms | 1732 KB | Output is partially correct |
78 | Partially correct | 719 ms | 1572 KB | Output is partially correct |
79 | Partially correct | 731 ms | 1640 KB | Output is partially correct |
80 | Partially correct | 697 ms | 1508 KB | Output is partially correct |
81 | Partially correct | 765 ms | 1428 KB | Output is partially correct |
82 | Partially correct | 711 ms | 1548 KB | Output is partially correct |