# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
850191 | 2023-09-16T01:57:50 Z | CodePlatina | 가장 긴 여행 (IOI23_longesttrip) | C++17 | 855 ms | 2036 KB |
#include "longesttrip.h" #include <iostream> #include <algorithm> #define pii pair<int, int> #define ff first #define ss second using namespace std; vector<int> gph[404]; bool chc[404]; bool vst[404]; void dfs(int x) { vst[x] = true; for(auto y : gph[x]) if(chc[y] && !vst[y]) dfs(y); } vector<vector<int>> cmpn(int N) { fill(vst, vst + N, false); for(int i = 0; i < N; ++i) if(chc[i]) { dfs(i); break; } vector<int> r1, r2; for(int i = 0; i < N; ++i) if(chc[i]) { if(vst[i]) r1.push_back(i); else r2.push_back(i); } if(r2.empty()) return {r1}; else return {r1, r2}; } vector<int> longest_trip(int N, int d) { for(int i = 0; i < N; ++i) gph[i].clear(); fill(chc, chc + N, true); for(int i = 0; i < N; ++i) { for(int j = i + 1; j < N; ++j) { if(are_connected(vector<int>{i}, vector<int>{j})) { gph[i].push_back(j); gph[j].push_back(i); } } } auto V = cmpn(N); if(V.size() == 2) { if(V[0].size() < V[1].size()) swap(V[0], V[1]); return V[0]; } int x; for(int i = 0; i < N; ++i) { chc[i] = false; if(cmpn(N).size() == 1) { x = i; break; } chc[i] = true; } vector<int> ret{x}; for(int k = 1; k < N; ++k) { for(auto i : gph[x]) if(chc[i]) { chc[i] = false; if(cmpn(N).size() == 1) { x = i; ret.push_back(x); break; } chc[i] = true; } } return ret; }
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 344 KB | Output is correct |
2 | Correct | 170 ms | 1908 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 6 ms | 344 KB | Output is correct |
2 | Correct | 25 ms | 344 KB | Output is correct |
3 | Correct | 127 ms | 856 KB | Output is correct |
4 | Correct | 369 ms | 1112 KB | Output is correct |
5 | Correct | 784 ms | 1116 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 7 ms | 344 KB | Output is correct |
2 | Correct | 26 ms | 344 KB | Output is correct |
3 | Correct | 122 ms | 860 KB | Output is correct |
4 | Correct | 358 ms | 1112 KB | Output is correct |
5 | Correct | 830 ms | 1528 KB | Output is correct |
6 | Correct | 8 ms | 344 KB | Output is correct |
7 | Correct | 21 ms | 344 KB | Output is correct |
8 | Correct | 117 ms | 1112 KB | Output is correct |
9 | Correct | 285 ms | 1224 KB | Output is correct |
10 | Correct | 750 ms | 1628 KB | Output is correct |
11 | Correct | 787 ms | 1496 KB | Output is correct |
12 | Correct | 769 ms | 1788 KB | Output is correct |
13 | Correct | 727 ms | 1524 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 | 704 KB | Output is correct |
4 | Correct | 373 ms | 960 KB | Output is correct |
5 | Correct | 770 ms | 1612 KB | Output is correct |
6 | Correct | 7 ms | 344 KB | Output is correct |
7 | Correct | 22 ms | 344 KB | Output is correct |
8 | Correct | 125 ms | 600 KB | Output is correct |
9 | Correct | 267 ms | 1368 KB | Output is correct |
10 | Correct | 812 ms | 1140 KB | Output is correct |
11 | Correct | 771 ms | 1632 KB | Output is correct |
12 | Correct | 710 ms | 1348 KB | Output is correct |
13 | Correct | 764 ms | 1252 KB | Output is correct |
14 | Correct | 7 ms | 344 KB | Output is correct |
15 | Correct | 11 ms | 592 KB | Output is correct |
16 | Correct | 38 ms | 344 KB | Output is correct |
17 | Correct | 71 ms | 600 KB | Output is correct |
18 | Correct | 124 ms | 600 KB | Output is correct |
19 | Correct | 284 ms | 1128 KB | Output is correct |
20 | Correct | 265 ms | 980 KB | Output is correct |
21 | Correct | 786 ms | 1936 KB | Output is correct |
22 | Correct | 799 ms | 1496 KB | Output is correct |
23 | Correct | 783 ms | 1256 KB | Output is correct |
24 | Correct | 789 ms | 1684 KB | Output is correct |
25 | Correct | 11 ms | 344 KB | Output is correct |
26 | Correct | 9 ms | 344 KB | Output is correct |
27 | Correct | 22 ms | 344 KB | Output is correct |
28 | Correct | 25 ms | 344 KB | Output is correct |
29 | Correct | 18 ms | 344 KB | Output is correct |
30 | Correct | 161 ms | 704 KB | Output is correct |
31 | Correct | 174 ms | 964 KB | Output is correct |
32 | Correct | 186 ms | 448 KB | Output is correct |
33 | Correct | 258 ms | 856 KB | Output is correct |
34 | Correct | 255 ms | 600 KB | Output is correct |
35 | Correct | 267 ms | 980 KB | Output is correct |
36 | Correct | 726 ms | 1488 KB | Output is correct |
37 | Correct | 752 ms | 1532 KB | Output is correct |
38 | Correct | 723 ms | 1316 KB | Output is correct |
39 | Correct | 772 ms | 1688 KB | Output is correct |
40 | Correct | 738 ms | 1652 KB | Output is correct |
41 | Correct | 765 ms | 1440 KB | Output is correct |
42 | Correct | 783 ms | 1268 KB | Output is correct |
43 | Correct | 744 ms | 1580 KB | Output is correct |
44 | Correct | 769 ms | 1432 KB | Output is correct |
45 | Correct | 9 ms | 344 KB | Output is correct |
46 | Correct | 7 ms | 340 KB | Output is correct |
47 | Correct | 19 ms | 344 KB | Output is correct |
48 | Correct | 28 ms | 344 KB | Output is correct |
49 | Correct | 23 ms | 344 KB | Output is correct |
50 | Correct | 173 ms | 956 KB | Output is correct |
51 | Correct | 157 ms | 1216 KB | Output is correct |
52 | Correct | 174 ms | 960 KB | Output is correct |
53 | Correct | 263 ms | 1216 KB | Output is correct |
54 | Correct | 261 ms | 724 KB | Output is correct |
55 | Correct | 286 ms | 1368 KB | Output is correct |
56 | Correct | 805 ms | 1628 KB | Output is correct |
57 | Correct | 766 ms | 1620 KB | Output is correct |
58 | Correct | 775 ms | 1788 KB | Output is correct |
59 | Correct | 757 ms | 1500 KB | Output is correct |
60 | Correct | 776 ms | 1760 KB | Output is correct |
61 | Correct | 772 ms | 976 KB | Output is correct |
62 | Correct | 712 ms | 1236 KB | Output is correct |
63 | Correct | 734 ms | 1340 KB | Output is correct |
64 | Correct | 814 ms | 1328 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 6 ms | 344 KB | Output is correct |
2 | Correct | 23 ms | 344 KB | Output is correct |
3 | Partially correct | 124 ms | 964 KB | Output is partially correct |
4 | Partially correct | 349 ms | 916 KB | Output is partially correct |
5 | Partially correct | 781 ms | 1252 KB | Output is partially correct |
6 | Correct | 7 ms | 344 KB | Output is correct |
7 | Correct | 23 ms | 344 KB | Output is correct |
8 | Partially correct | 125 ms | 600 KB | Output is partially correct |
9 | Partially correct | 286 ms | 956 KB | Output is partially correct |
10 | Partially correct | 811 ms | 1672 KB | Output is partially correct |
11 | Partially correct | 774 ms | 1188 KB | Output is partially correct |
12 | Partially correct | 767 ms | 1884 KB | Output is partially correct |
13 | Partially correct | 747 ms | 1400 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 | 37 ms | 344 KB | Output is correct |
17 | Partially correct | 76 ms | 856 KB | Output is partially correct |
18 | Partially correct | 113 ms | 600 KB | Output is partially correct |
19 | Partially correct | 275 ms | 1368 KB | Output is partially correct |
20 | Partially correct | 270 ms | 1368 KB | Output is partially correct |
21 | Correct | 9 ms | 344 KB | Output is correct |
22 | Correct | 10 ms | 344 KB | Output is correct |
23 | Correct | 25 ms | 344 KB | Output is correct |
24 | Correct | 25 ms | 344 KB | Output is correct |
25 | Correct | 28 ms | 344 KB | Output is correct |
26 | Partially correct | 180 ms | 960 KB | Output is partially correct |
27 | Partially correct | 181 ms | 960 KB | Output is partially correct |
28 | Partially correct | 163 ms | 964 KB | Output is partially correct |
29 | Partially correct | 259 ms | 732 KB | Output is partially correct |
30 | Partially correct | 247 ms | 844 KB | Output is partially correct |
31 | Partially correct | 279 ms | 852 KB | Output is partially correct |
32 | Correct | 9 ms | 344 KB | Output is correct |
33 | Correct | 9 ms | 344 KB | Output is correct |
34 | Correct | 22 ms | 344 KB | Output is correct |
35 | Correct | 24 ms | 344 KB | Output is correct |
36 | Correct | 27 ms | 344 KB | Output is correct |
37 | Partially correct | 161 ms | 704 KB | Output is partially correct |
38 | Partially correct | 173 ms | 444 KB | Output is partially correct |
39 | Partially correct | 159 ms | 700 KB | Output is partially correct |
40 | Partially correct | 271 ms | 724 KB | Output is partially correct |
41 | Partially correct | 272 ms | 964 KB | Output is partially correct |
42 | Partially correct | 261 ms | 856 KB | Output is partially correct |
43 | Partially correct | 723 ms | 1680 KB | Output is partially correct |
44 | Partially correct | 747 ms | 1824 KB | Output is partially correct |
45 | Partially correct | 786 ms | 1408 KB | Output is partially correct |
46 | Partially correct | 804 ms | 1256 KB | Output is partially correct |
47 | Partially correct | 777 ms | 1368 KB | Output is partially correct |
48 | Partially correct | 699 ms | 1736 KB | Output is partially correct |
49 | Partially correct | 730 ms | 1484 KB | Output is partially correct |
50 | Partially correct | 728 ms | 1616 KB | Output is partially correct |
51 | Partially correct | 739 ms | 1884 KB | Output is partially correct |
52 | Partially correct | 752 ms | 1772 KB | Output is partially correct |
53 | Partially correct | 757 ms | 1284 KB | Output is partially correct |
54 | Partially correct | 795 ms | 1592 KB | Output is partially correct |
55 | Partially correct | 770 ms | 1556 KB | Output is partially correct |
56 | Partially correct | 798 ms | 1880 KB | Output is partially correct |
57 | Partially correct | 723 ms | 1600 KB | Output is partially correct |
58 | Partially correct | 804 ms | 1600 KB | Output is partially correct |
59 | Partially correct | 779 ms | 1436 KB | Output is partially correct |
60 | Partially correct | 734 ms | 1508 KB | Output is partially correct |
61 | Partially correct | 762 ms | 1248 KB | Output is partially correct |
62 | Partially correct | 775 ms | 1852 KB | Output is partially correct |
63 | Partially correct | 855 ms | 1296 KB | Output is partially correct |
64 | Partially correct | 767 ms | 2036 KB | Output is partially correct |
65 | Partially correct | 762 ms | 1368 KB | Output is partially correct |
66 | Partially correct | 794 ms | 1256 KB | Output is partially correct |
67 | Partially correct | 767 ms | 848 KB | Output is partially correct |
68 | Partially correct | 763 ms | 1164 KB | Output is partially correct |
69 | Partially correct | 782 ms | 1532 KB | Output is partially correct |
70 | Partially correct | 814 ms | 1596 KB | Output is partially correct |
71 | Partially correct | 765 ms | 1544 KB | Output is partially correct |
72 | Partially correct | 764 ms | 1192 KB | Output is partially correct |
73 | Partially correct | 784 ms | 1504 KB | Output is partially correct |
74 | Partially correct | 792 ms | 1564 KB | Output is partially correct |
75 | Partially correct | 746 ms | 1040 KB | Output is partially correct |
76 | Partially correct | 722 ms | 1540 KB | Output is partially correct |
77 | Partially correct | 782 ms | 1132 KB | Output is partially correct |
78 | Partially correct | 790 ms | 1856 KB | Output is partially correct |
79 | Partially correct | 772 ms | 1788 KB | Output is partially correct |
80 | Partially correct | 812 ms | 1764 KB | Output is partially correct |
81 | Partially correct | 737 ms | 1220 KB | Output is partially correct |
82 | Partially correct | 780 ms | 1532 KB | Output is partially correct |