# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
1046915 | 2024-08-07T06:14:25 Z | sonamoo | 가장 긴 여행 (IOI23_longesttrip) | C++17 | 576 ms | 856 KB |
#include "longesttrip.h" #include <bits/stdc++.h> using namespace std; vector<int> ans , ans2; int vis[260]; int graph[260][260]; void init() { ans.clear(); ans2.clear(); memset(graph , 0 , sizeof(graph)); memset(vis , 0 , sizeof(vis)); } vector<int> longest_trip(int N, int D) { init(); int here = 0; vis[0]=1; ans.push_back(0); int prv=-1; while(prv!=here) { prv=here; for (int i = 0; i < N; i++) { vector<int> tmp1 , tmp2; if (vis[i]==0) { tmp1.push_back(i); tmp2.push_back(here); if (!are_connected(tmp1 , tmp2)) continue; ans.push_back(i); vis[i]=1; here=i; break; } } } if (D == 2) { if (ans.size() == N) return ans; reverse(ans.begin() , ans.end()); for (int i = 0; i < N; i++) if (vis[i]==0) ans.push_back(i); return ans; } if (D == 3) { for (int i = 0; i < N; i++) ans2.push_back(i); return ans2; } for (int i = 0; i < N; i++) if (vis[i] == 0) ans2.push_back(i); for (int i = 0; i < ans2.size(); i++) { vector<int> tmp1 , tmp2; tmp1.push_back(ans[0]); tmp2.push_back(ans2[i]); if (are_connected(tmp1 , tmp2)) { vector<int> ANS; for (int j = 0; j < ans2.size(); j++) if (j != i) ANS.push_back(ans2[j]); ANS.push_back(ans2[i]); for (auto t : ans) ANS.push_back(t); return ANS; } } for (int i = 1; i < ans.size()-1; i++) { for (int j = 0; j < ans2.size(); j++) { vector<int> tmp1 , tmp2; tmp1.push_back(ans[i]); tmp2.push_back(ans2[j]); if (are_connected(tmp1 , tmp2)) { vector<int> ANS; for (int k = 0; k < ans2.size(); k++) if (k != j) ANS.push_back(ans2[k]); ANS.push_back(ans2[j]); for (int k = i; k < ans.size(); k++) ANS.push_back(ans[k]); for (int k = 0; k < i; k++) ANS.push_back(ans[k]); return ANS; } } } if (ans2.size() < ans.size()) return ans; return ans2; }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 600 KB | Output is correct |
2 | Correct | 1 ms | 600 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 5 ms | 600 KB | Output is correct |
2 | Correct | 7 ms | 600 KB | Output is correct |
3 | Correct | 4 ms | 600 KB | Output is correct |
4 | Correct | 4 ms | 600 KB | Output is correct |
5 | Correct | 5 ms | 600 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 5 ms | 600 KB | Output is correct |
2 | Correct | 5 ms | 600 KB | Output is correct |
3 | Correct | 4 ms | 600 KB | Output is correct |
4 | Correct | 4 ms | 600 KB | Output is correct |
5 | Correct | 5 ms | 600 KB | Output is correct |
6 | Correct | 6 ms | 600 KB | Output is correct |
7 | Correct | 6 ms | 600 KB | Output is correct |
8 | Correct | 5 ms | 600 KB | Output is correct |
9 | Correct | 4 ms | 600 KB | Output is correct |
10 | Correct | 4 ms | 692 KB | Output is correct |
11 | Correct | 5 ms | 600 KB | Output is correct |
12 | Correct | 5 ms | 600 KB | Output is correct |
13 | Correct | 5 ms | 600 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 6 ms | 600 KB | Output is correct |
2 | Correct | 5 ms | 600 KB | Output is correct |
3 | Correct | 6 ms | 600 KB | Output is correct |
4 | Correct | 6 ms | 600 KB | Output is correct |
5 | Correct | 4 ms | 700 KB | Output is correct |
6 | Correct | 8 ms | 604 KB | Output is correct |
7 | Correct | 5 ms | 600 KB | Output is correct |
8 | Correct | 5 ms | 604 KB | Output is correct |
9 | Correct | 8 ms | 600 KB | Output is correct |
10 | Correct | 5 ms | 600 KB | Output is correct |
11 | Correct | 5 ms | 600 KB | Output is correct |
12 | Correct | 5 ms | 600 KB | Output is correct |
13 | Correct | 5 ms | 600 KB | Output is correct |
14 | Correct | 8 ms | 600 KB | Output is correct |
15 | Correct | 9 ms | 600 KB | Output is correct |
16 | Correct | 7 ms | 600 KB | Output is correct |
17 | Correct | 6 ms | 600 KB | Output is correct |
18 | Correct | 6 ms | 600 KB | Output is correct |
19 | Correct | 8 ms | 600 KB | Output is correct |
20 | Correct | 4 ms | 600 KB | Output is correct |
21 | Correct | 5 ms | 600 KB | Output is correct |
22 | Correct | 5 ms | 600 KB | Output is correct |
23 | Correct | 5 ms | 600 KB | Output is correct |
24 | Correct | 5 ms | 600 KB | Output is correct |
25 | Correct | 8 ms | 600 KB | Output is correct |
26 | Correct | 8 ms | 600 KB | Output is correct |
27 | Correct | 9 ms | 600 KB | Output is correct |
28 | Correct | 10 ms | 600 KB | Output is correct |
29 | Correct | 11 ms | 600 KB | Output is correct |
30 | Correct | 10 ms | 600 KB | Output is correct |
31 | Correct | 92 ms | 600 KB | Output is correct |
32 | Correct | 117 ms | 600 KB | Output is correct |
33 | Correct | 11 ms | 600 KB | Output is correct |
34 | Correct | 18 ms | 600 KB | Output is correct |
35 | Correct | 43 ms | 600 KB | Output is correct |
36 | Correct | 9 ms | 600 KB | Output is correct |
37 | Correct | 94 ms | 600 KB | Output is correct |
38 | Correct | 266 ms | 600 KB | Output is correct |
39 | Correct | 454 ms | 600 KB | Output is correct |
40 | Correct | 462 ms | 684 KB | Output is correct |
41 | Correct | 527 ms | 676 KB | Output is correct |
42 | Correct | 519 ms | 672 KB | Output is correct |
43 | Correct | 530 ms | 844 KB | Output is correct |
44 | Correct | 536 ms | 680 KB | Output is correct |
45 | Correct | 8 ms | 600 KB | Output is correct |
46 | Correct | 7 ms | 600 KB | Output is correct |
47 | Correct | 6 ms | 600 KB | Output is correct |
48 | Correct | 9 ms | 600 KB | Output is correct |
49 | Correct | 7 ms | 600 KB | Output is correct |
50 | Correct | 6 ms | 600 KB | Output is correct |
51 | Correct | 43 ms | 600 KB | Output is correct |
52 | Correct | 63 ms | 600 KB | Output is correct |
53 | Correct | 6 ms | 600 KB | Output is correct |
54 | Correct | 10 ms | 600 KB | Output is correct |
55 | Correct | 15 ms | 856 KB | Output is correct |
56 | Correct | 6 ms | 856 KB | Output is correct |
57 | Correct | 23 ms | 600 KB | Output is correct |
58 | Correct | 72 ms | 600 KB | Output is correct |
59 | Correct | 117 ms | 700 KB | Output is correct |
60 | Correct | 251 ms | 848 KB | Output is correct |
61 | Correct | 208 ms | 696 KB | Output is correct |
62 | Correct | 164 ms | 680 KB | Output is correct |
63 | Correct | 274 ms | 600 KB | Output is correct |
64 | Correct | 227 ms | 600 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 6 ms | 600 KB | Output is correct |
2 | Correct | 4 ms | 600 KB | Output is correct |
3 | Correct | 5 ms | 600 KB | Output is correct |
4 | Correct | 4 ms | 600 KB | Output is correct |
5 | Correct | 4 ms | 596 KB | Output is correct |
6 | Correct | 9 ms | 600 KB | Output is correct |
7 | Correct | 6 ms | 600 KB | Output is correct |
8 | Correct | 4 ms | 600 KB | Output is correct |
9 | Correct | 4 ms | 600 KB | Output is correct |
10 | Correct | 5 ms | 600 KB | Output is correct |
11 | Correct | 4 ms | 600 KB | Output is correct |
12 | Correct | 5 ms | 600 KB | Output is correct |
13 | Correct | 6 ms | 536 KB | Output is correct |
14 | Correct | 8 ms | 600 KB | Output is correct |
15 | Correct | 10 ms | 600 KB | Output is correct |
16 | Correct | 11 ms | 600 KB | Output is correct |
17 | Correct | 6 ms | 600 KB | Output is correct |
18 | Correct | 6 ms | 600 KB | Output is correct |
19 | Correct | 5 ms | 856 KB | Output is correct |
20 | Correct | 5 ms | 600 KB | Output is correct |
21 | Correct | 9 ms | 600 KB | Output is correct |
22 | Correct | 8 ms | 600 KB | Output is correct |
23 | Correct | 9 ms | 600 KB | Output is correct |
24 | Correct | 10 ms | 600 KB | Output is correct |
25 | Correct | 9 ms | 600 KB | Output is correct |
26 | Correct | 10 ms | 600 KB | Output is correct |
27 | Partially correct | 99 ms | 600 KB | Output is partially correct |
28 | Partially correct | 129 ms | 600 KB | Output is partially correct |
29 | Correct | 10 ms | 600 KB | Output is correct |
30 | Partially correct | 14 ms | 600 KB | Output is partially correct |
31 | Partially correct | 33 ms | 596 KB | Output is partially correct |
32 | Correct | 7 ms | 600 KB | Output is correct |
33 | Correct | 12 ms | 600 KB | Output is correct |
34 | Correct | 7 ms | 600 KB | Output is correct |
35 | Correct | 6 ms | 600 KB | Output is correct |
36 | Correct | 6 ms | 600 KB | Output is correct |
37 | Correct | 6 ms | 600 KB | Output is correct |
38 | Partially correct | 51 ms | 600 KB | Output is partially correct |
39 | Partially correct | 63 ms | 600 KB | Output is partially correct |
40 | Correct | 7 ms | 856 KB | Output is correct |
41 | Partially correct | 10 ms | 600 KB | Output is partially correct |
42 | Partially correct | 13 ms | 664 KB | Output is partially correct |
43 | Correct | 6 ms | 600 KB | Output is correct |
44 | Correct | 5 ms | 600 KB | Output is correct |
45 | Correct | 5 ms | 600 KB | Output is correct |
46 | Correct | 5 ms | 600 KB | Output is correct |
47 | Partially correct | 12 ms | 600 KB | Output is partially correct |
48 | Partially correct | 78 ms | 600 KB | Output is partially correct |
49 | Partially correct | 248 ms | 600 KB | Output is partially correct |
50 | Partially correct | 427 ms | 600 KB | Output is partially correct |
51 | Partially correct | 510 ms | 600 KB | Output is partially correct |
52 | Partially correct | 526 ms | 680 KB | Output is partially correct |
53 | Partially correct | 576 ms | 680 KB | Output is partially correct |
54 | Partially correct | 518 ms | 676 KB | Output is partially correct |
55 | Partially correct | 532 ms | 600 KB | Output is partially correct |
56 | Partially correct | 113 ms | 600 KB | Output is partially correct |
57 | Partially correct | 312 ms | 856 KB | Output is partially correct |
58 | Partially correct | 457 ms | 600 KB | Output is partially correct |
59 | Partially correct | 534 ms | 684 KB | Output is partially correct |
60 | Partially correct | 501 ms | 684 KB | Output is partially correct |
61 | Partially correct | 524 ms | 680 KB | Output is partially correct |
62 | Partially correct | 6 ms | 852 KB | Output is partially correct |
63 | Partially correct | 20 ms | 600 KB | Output is partially correct |
64 | Partially correct | 82 ms | 680 KB | Output is partially correct |
65 | Partially correct | 148 ms | 600 KB | Output is partially correct |
66 | Partially correct | 237 ms | 700 KB | Output is partially correct |
67 | Partially correct | 226 ms | 848 KB | Output is partially correct |
68 | Partially correct | 168 ms | 680 KB | Output is partially correct |
69 | Partially correct | 262 ms | 600 KB | Output is partially correct |
70 | Partially correct | 205 ms | 680 KB | Output is partially correct |
71 | Partially correct | 25 ms | 600 KB | Output is partially correct |
72 | Partially correct | 168 ms | 600 KB | Output is partially correct |
73 | Partially correct | 202 ms | 600 KB | Output is partially correct |
74 | Partially correct | 205 ms | 680 KB | Output is partially correct |
75 | Partially correct | 142 ms | 600 KB | Output is partially correct |
76 | Partially correct | 294 ms | 600 KB | Output is partially correct |
77 | Partially correct | 34 ms | 600 KB | Output is partially correct |
78 | Partially correct | 130 ms | 856 KB | Output is partially correct |
79 | Partially correct | 132 ms | 696 KB | Output is partially correct |
80 | Partially correct | 275 ms | 680 KB | Output is partially correct |
81 | Partially correct | 184 ms | 852 KB | Output is partially correct |
82 | Partially correct | 145 ms | 600 KB | Output is partially correct |