# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1072443 | 2024-08-23T19:08:56 Z | HorizonWest | Longest Trip (IOI23_longesttrip) | C++17 | 996 ms | 1608 KB |
#include <iostream> #include <complex> #include <iomanip> #include <vector> #include <algorithm> #include <functional> #include <bitset> #include <queue> #include <map> #include <stack> #include <cmath> #include <cstdint> #include <cassert> #include "longesttrip.h" using namespace std; vector <int> longest_trip(int n, int d) { vector <vector<int>> v(n, vector <int> ()), s(n, vector <int> (n, -1)); auto add = [&] (int a, int b) -> void { if(s[a][b] == -1){ s[a][b] = s[b][a] = 1; v[a].push_back(b); v[b].push_back(a); } }; if(d == 3){ for(int i = 0; i < n; i++){ for(int j = i+1; j < n; j++) { add(i, j); } } }else if(d == 2){ for(int i = 0; i < n; i++) { for(int j = i+1; j < n; j++) { if(s[i][j] == -1){ s[i][j] = are_connected({ i }, { j }); if(s[i][j] == 1){ s[i][j] = -1; add(i, j); } } } } } else if(d == 1){ for(int i = 0; i < n; i++) { for(int j = i+1; j < n; j++) { if(s[i][j] == -1){ s[i][j] = are_connected({ i }, { j }); if(s[i][j] == 1) { s[i][j] = -1; add(i, j); } } } } } vector <int> pass(n), ans, path; auto dfs = [&] (auto dfs, int node, int parent) -> void { path.push_back(node); pass[node] = 1; if(path.size() > ans.size()) ans = path; for(auto& u : v[node]) if(!pass[u]){ if(v[u].size() != n) dfs(dfs, u, node); } for(auto& u : v[node]) if(!pass[u]) { dfs(dfs, u, node); } path.pop_back(); }; for(int i = 0; i < n; i++){ for(int j = 0; j < n; j++){ pass[j] = 0; } if(ans.size() == n) break; dfs(dfs, i, i); } return ans; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 344 KB | Output is correct |
2 | Correct | 197 ms | 1540 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 344 KB | Output is correct |
2 | Correct | 2 ms | 344 KB | Output is correct |
3 | Correct | 2 ms | 344 KB | Output is correct |
4 | Correct | 2 ms | 628 KB | Output is correct |
5 | Correct | 2 ms | 1072 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 10 ms | 344 KB | Output is correct |
2 | Correct | 28 ms | 344 KB | Output is correct |
3 | Correct | 180 ms | 468 KB | Output is correct |
4 | Correct | 456 ms | 580 KB | Output is correct |
5 | Correct | 898 ms | 1364 KB | Output is correct |
6 | Correct | 10 ms | 344 KB | Output is correct |
7 | Correct | 22 ms | 344 KB | Output is correct |
8 | Correct | 151 ms | 456 KB | Output is correct |
9 | Correct | 344 ms | 804 KB | Output is correct |
10 | Correct | 862 ms | 1380 KB | Output is correct |
11 | Correct | 880 ms | 1312 KB | Output is correct |
12 | Correct | 892 ms | 1328 KB | Output is correct |
13 | Correct | 897 ms | 1080 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 5 ms | 344 KB | Output is correct |
2 | Correct | 22 ms | 344 KB | Output is correct |
3 | Correct | 149 ms | 472 KB | Output is correct |
4 | Correct | 439 ms | 824 KB | Output is correct |
5 | Correct | 847 ms | 1312 KB | Output is correct |
6 | Correct | 7 ms | 344 KB | Output is correct |
7 | Correct | 26 ms | 344 KB | Output is correct |
8 | Correct | 155 ms | 600 KB | Output is correct |
9 | Correct | 326 ms | 600 KB | Output is correct |
10 | Correct | 879 ms | 1276 KB | Output is correct |
11 | Correct | 855 ms | 1364 KB | Output is correct |
12 | Correct | 887 ms | 1448 KB | Output is correct |
13 | Correct | 915 ms | 1520 KB | Output is correct |
14 | Correct | 8 ms | 344 KB | Output is correct |
15 | Correct | 11 ms | 344 KB | Output is correct |
16 | Correct | 47 ms | 344 KB | Output is correct |
17 | Correct | 94 ms | 344 KB | Output is correct |
18 | Correct | 142 ms | 600 KB | Output is correct |
19 | Correct | 353 ms | 736 KB | Output is correct |
20 | Correct | 343 ms | 848 KB | Output is correct |
21 | Correct | 911 ms | 1104 KB | Output is correct |
22 | Correct | 858 ms | 1344 KB | Output is correct |
23 | Correct | 836 ms | 1516 KB | Output is correct |
24 | Correct | 900 ms | 1364 KB | Output is correct |
25 | Correct | 9 ms | 344 KB | Output is correct |
26 | Correct | 9 ms | 344 KB | Output is correct |
27 | Correct | 25 ms | 424 KB | Output is correct |
28 | Correct | 23 ms | 592 KB | Output is correct |
29 | Correct | 19 ms | 344 KB | Output is correct |
30 | Correct | 229 ms | 344 KB | Output is correct |
31 | Correct | 202 ms | 344 KB | Output is correct |
32 | Correct | 218 ms | 456 KB | Output is correct |
33 | Correct | 318 ms | 544 KB | Output is correct |
34 | Correct | 353 ms | 760 KB | Output is correct |
35 | Correct | 348 ms | 760 KB | Output is correct |
36 | Correct | 996 ms | 1308 KB | Output is correct |
37 | Correct | 939 ms | 1288 KB | Output is correct |
38 | Correct | 885 ms | 1364 KB | Output is correct |
39 | Correct | 913 ms | 1068 KB | Output is correct |
40 | Correct | 892 ms | 1228 KB | Output is correct |
41 | Correct | 857 ms | 1032 KB | Output is correct |
42 | Correct | 901 ms | 1244 KB | Output is correct |
43 | Correct | 928 ms | 1064 KB | Output is correct |
44 | Correct | 911 ms | 1180 KB | Output is correct |
45 | Correct | 7 ms | 344 KB | Output is correct |
46 | Correct | 10 ms | 344 KB | Output is correct |
47 | Correct | 33 ms | 344 KB | Output is correct |
48 | Correct | 25 ms | 344 KB | Output is correct |
49 | Correct | 27 ms | 344 KB | Output is correct |
50 | Correct | 184 ms | 480 KB | Output is correct |
51 | Correct | 233 ms | 600 KB | Output is correct |
52 | Correct | 197 ms | 464 KB | Output is correct |
53 | Correct | 349 ms | 592 KB | Output is correct |
54 | Correct | 336 ms | 600 KB | Output is correct |
55 | Correct | 331 ms | 500 KB | Output is correct |
56 | Correct | 977 ms | 1552 KB | Output is correct |
57 | Correct | 931 ms | 1208 KB | Output is correct |
58 | Correct | 993 ms | 1364 KB | Output is correct |
59 | Correct | 920 ms | 1296 KB | Output is correct |
60 | Correct | 914 ms | 1488 KB | Output is correct |
61 | Correct | 917 ms | 1004 KB | Output is correct |
62 | Correct | 902 ms | 1608 KB | Output is correct |
63 | Correct | 893 ms | 1364 KB | Output is correct |
64 | Correct | 906 ms | 1200 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 6 ms | 344 KB | Output is correct |
2 | Correct | 31 ms | 344 KB | Output is correct |
3 | Partially correct | 149 ms | 456 KB | Output is partially correct |
4 | Partially correct | 416 ms | 764 KB | Output is partially correct |
5 | Partially correct | 832 ms | 1396 KB | Output is partially correct |
6 | Correct | 7 ms | 344 KB | Output is correct |
7 | Correct | 21 ms | 344 KB | Output is correct |
8 | Partially correct | 140 ms | 456 KB | Output is partially correct |
9 | Partially correct | 299 ms | 556 KB | Output is partially correct |
10 | Partially correct | 878 ms | 1240 KB | Output is partially correct |
11 | Partially correct | 895 ms | 1264 KB | Output is partially correct |
12 | Partially correct | 863 ms | 1352 KB | Output is partially correct |
13 | Partially correct | 897 ms | 1484 KB | Output is partially correct |
14 | Correct | 8 ms | 356 KB | Output is correct |
15 | Correct | 9 ms | 344 KB | Output is correct |
16 | Incorrect | 7 ms | 344 KB | Incorrect |
17 | Halted | 0 ms | 0 KB | - |