# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1080934 | 2024-08-29T16:06:09 Z | asdasdqwer | Longest Trip (IOI23_longesttrip) | C++17 | 929 ms | 1324 KB |
#include "longesttrip.h" #include <bits/stdc++.h> using namespace std; std::vector<int> longest_trip(int N, int D) { vector<vector<int>> g(N); if (D == 3) { vector<int> v; for (int i=0;i<N;i++) { v.push_back(i); } return v; } for (int i=0;i<N;i++) { for (int j=i+1;j<N;j++) { if (are_connected({i}, {j})) { g[i].push_back(j); g[j].push_back(i); } } } int tries = 17; mt19937 rng(chrono::steady_clock::now().time_since_epoch().count()); for (int i=0;i<N;i++) { shuffle(g[i].begin(), g[i].end(), rng); } vector<int> lng; for (int i=0;i<N;i++) { vector<int> tmp; vector<bool> vis(N, false); function<void(int)> dfs=[&](int node) { vis[node] = true; tmp.push_back(node); for (int x:g[node]) { if (!vis[x]) { dfs(x); break; } } }; dfs(i); if (lng.size() < tmp.size()) { lng = tmp; } if ((D == 2 && lng.size() == N) || (D == 1 && lng.size() >= (N/2+1))) return lng; } return lng; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 344 KB | Output is correct |
2 | Incorrect | 222 ms | 1064 KB | Incorrect |
3 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 344 KB | Output is correct |
2 | Correct | 1 ms | 344 KB | Output is correct |
3 | Correct | 1 ms | 344 KB | Output is correct |
4 | Correct | 1 ms | 344 KB | Output is correct |
5 | Correct | 0 ms | 344 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 8 ms | 344 KB | Output is correct |
2 | Correct | 24 ms | 344 KB | Output is correct |
3 | Correct | 142 ms | 600 KB | Output is correct |
4 | Correct | 384 ms | 724 KB | Output is correct |
5 | Correct | 872 ms | 988 KB | Output is correct |
6 | Correct | 10 ms | 344 KB | Output is correct |
7 | Correct | 31 ms | 344 KB | Output is correct |
8 | Correct | 147 ms | 344 KB | Output is correct |
9 | Correct | 359 ms | 736 KB | Output is correct |
10 | Correct | 803 ms | 820 KB | Output is correct |
11 | Correct | 860 ms | 1020 KB | Output is correct |
12 | Correct | 862 ms | 1312 KB | Output is correct |
13 | Correct | 871 ms | 756 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 8 ms | 344 KB | Output is correct |
2 | Correct | 31 ms | 344 KB | Output is correct |
3 | Correct | 164 ms | 464 KB | Output is correct |
4 | Correct | 426 ms | 344 KB | Output is correct |
5 | Correct | 887 ms | 1204 KB | Output is correct |
6 | Correct | 7 ms | 344 KB | Output is correct |
7 | Correct | 26 ms | 344 KB | Output is correct |
8 | Correct | 138 ms | 440 KB | Output is correct |
9 | Correct | 312 ms | 500 KB | Output is correct |
10 | Correct | 862 ms | 1324 KB | Output is correct |
11 | Correct | 796 ms | 748 KB | Output is correct |
12 | Correct | 855 ms | 1056 KB | Output is correct |
13 | Correct | 789 ms | 936 KB | Output is correct |
14 | Correct | 7 ms | 344 KB | Output is correct |
15 | Correct | 15 ms | 344 KB | Output is correct |
16 | Correct | 49 ms | 344 KB | Output is correct |
17 | Correct | 94 ms | 344 KB | Output is correct |
18 | Correct | 146 ms | 344 KB | Output is correct |
19 | Correct | 305 ms | 720 KB | Output is correct |
20 | Correct | 348 ms | 496 KB | Output is correct |
21 | Correct | 888 ms | 992 KB | Output is correct |
22 | Correct | 856 ms | 1156 KB | Output is correct |
23 | Correct | 834 ms | 1292 KB | Output is correct |
24 | Correct | 843 ms | 1172 KB | Output is correct |
25 | Correct | 10 ms | 344 KB | Output is correct |
26 | Correct | 9 ms | 344 KB | Output is correct |
27 | Correct | 31 ms | 344 KB | Output is correct |
28 | Correct | 33 ms | 344 KB | Output is correct |
29 | Correct | 25 ms | 344 KB | Output is correct |
30 | Correct | 196 ms | 344 KB | Output is correct |
31 | Correct | 173 ms | 344 KB | Output is correct |
32 | Correct | 196 ms | 452 KB | Output is correct |
33 | Correct | 271 ms | 440 KB | Output is correct |
34 | Correct | 282 ms | 728 KB | Output is correct |
35 | Correct | 286 ms | 608 KB | Output is correct |
36 | Correct | 739 ms | 1236 KB | Output is correct |
37 | Correct | 785 ms | 856 KB | Output is correct |
38 | Correct | 811 ms | 1104 KB | Output is correct |
39 | Correct | 753 ms | 884 KB | Output is correct |
40 | Correct | 813 ms | 844 KB | Output is correct |
41 | Correct | 801 ms | 780 KB | Output is correct |
42 | Correct | 771 ms | 832 KB | Output is correct |
43 | Correct | 865 ms | 796 KB | Output is correct |
44 | Correct | 873 ms | 992 KB | Output is correct |
45 | Correct | 11 ms | 344 KB | Output is correct |
46 | Correct | 10 ms | 344 KB | Output is correct |
47 | Correct | 23 ms | 344 KB | Output is correct |
48 | Correct | 21 ms | 344 KB | Output is correct |
49 | Correct | 18 ms | 344 KB | Output is correct |
50 | Correct | 213 ms | 344 KB | Output is correct |
51 | Correct | 209 ms | 344 KB | Output is correct |
52 | Correct | 188 ms | 436 KB | Output is correct |
53 | Correct | 328 ms | 476 KB | Output is correct |
54 | Correct | 317 ms | 496 KB | Output is correct |
55 | Correct | 307 ms | 488 KB | Output is correct |
56 | Correct | 854 ms | 1112 KB | Output is correct |
57 | Correct | 862 ms | 876 KB | Output is correct |
58 | Correct | 858 ms | 1048 KB | Output is correct |
59 | Correct | 842 ms | 1188 KB | Output is correct |
60 | Correct | 929 ms | 976 KB | Output is correct |
61 | Correct | 856 ms | 888 KB | Output is correct |
62 | Correct | 851 ms | 992 KB | Output is correct |
63 | Correct | 898 ms | 748 KB | Output is correct |
64 | Correct | 856 ms | 792 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 8 ms | 344 KB | Output is correct |
2 | Correct | 23 ms | 344 KB | Output is correct |
3 | Partially correct | 169 ms | 436 KB | Output is partially correct |
4 | Partially correct | 401 ms | 712 KB | Output is partially correct |
5 | Partially correct | 859 ms | 900 KB | Output is partially correct |
6 | Incorrect | 0 ms | 344 KB | Incorrect |
7 | Halted | 0 ms | 0 KB | - |