# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1069827 | 2024-08-22T09:15:43 Z | Muhammad_Aneeq | Longest Trip (IOI23_longesttrip) | C++17 | 921 ms | 1408 KB |
#include <vector> #include <set> #include "longesttrip.h" using namespace std; int const MAXN=256; vector<int>nei[MAXN]={}; vector<int>ans; vector<int>cur; bool vis[MAXN]={}; void dfs(int u,int p=-1) { vis[u]=1; cur.push_back(u); bool w=0; for (auto i:nei[u]) { if (vis[i]) continue; w=1; dfs(i,u); } if (cur.size()>ans.size()) ans=cur; cur.pop_back(); } vector<int> sol(int N) { vector<int>ans; for (int i=0;i<N;i++) { int q=i; vector<int>cur; while(!vis[q]) { vis[q]=1; cur.push_back(q); for (auto i:nei[q]) { if (!vis[i]) { q=i; break; } } } if (cur.size()>ans.size()) ans=cur; } return ans; } vector<int> longest_trip(int N, int D) { ans={}; cur={}; for (int i=0;i<N;i++) nei[i]={},vis[i]=0; for (int i=0;i<N;i++) for (int j=i+1;j<N;j++) if (are_connected({i},{j})) nei[i].push_back(j),nei[j].push_back(i); if (D==1) { return sol(N); } for (int i=0;i<N;i++) { for (int j=0;j<N;j++) vis[j]=0; dfs(i); } return ans; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 344 KB | Output is correct |
2 | Correct | 207 ms | 1080 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 9 ms | 344 KB | Output is correct |
2 | Correct | 45 ms | 344 KB | Output is correct |
3 | Correct | 154 ms | 344 KB | Output is correct |
4 | Correct | 379 ms | 700 KB | Output is correct |
5 | Correct | 853 ms | 1236 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 10 ms | 344 KB | Output is correct |
2 | Correct | 19 ms | 344 KB | Output is correct |
3 | Correct | 146 ms | 600 KB | Output is correct |
4 | Correct | 445 ms | 696 KB | Output is correct |
5 | Correct | 921 ms | 876 KB | Output is correct |
6 | Correct | 7 ms | 344 KB | Output is correct |
7 | Correct | 22 ms | 344 KB | Output is correct |
8 | Correct | 152 ms | 344 KB | Output is correct |
9 | Correct | 298 ms | 344 KB | Output is correct |
10 | Correct | 899 ms | 1056 KB | Output is correct |
11 | Correct | 883 ms | 728 KB | Output is correct |
12 | Correct | 871 ms | 828 KB | Output is correct |
13 | Correct | 896 ms | 1320 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 4 ms | 596 KB | Output is correct |
2 | Correct | 22 ms | 344 KB | Output is correct |
3 | Correct | 144 ms | 344 KB | Output is correct |
4 | Correct | 415 ms | 344 KB | Output is correct |
5 | Correct | 825 ms | 1356 KB | Output is correct |
6 | Correct | 6 ms | 344 KB | Output is correct |
7 | Correct | 21 ms | 344 KB | Output is correct |
8 | Correct | 137 ms | 344 KB | Output is correct |
9 | Correct | 282 ms | 592 KB | Output is correct |
10 | Correct | 849 ms | 780 KB | Output is correct |
11 | Correct | 826 ms | 988 KB | Output is correct |
12 | Correct | 828 ms | 768 KB | Output is correct |
13 | Correct | 826 ms | 856 KB | Output is correct |
14 | Correct | 6 ms | 344 KB | Output is correct |
15 | Correct | 10 ms | 344 KB | Output is correct |
16 | Correct | 32 ms | 344 KB | Output is correct |
17 | Correct | 101 ms | 344 KB | Output is correct |
18 | Correct | 148 ms | 344 KB | Output is correct |
19 | Correct | 313 ms | 680 KB | Output is correct |
20 | Correct | 293 ms | 448 KB | Output is correct |
21 | Correct | 798 ms | 984 KB | Output is correct |
22 | Correct | 817 ms | 1136 KB | Output is correct |
23 | Correct | 861 ms | 952 KB | Output is correct |
24 | Correct | 825 ms | 1136 KB | Output is correct |
25 | Correct | 7 ms | 344 KB | Output is correct |
26 | Correct | 8 ms | 344 KB | Output is correct |
27 | Correct | 34 ms | 344 KB | Output is correct |
28 | Correct | 20 ms | 344 KB | Output is correct |
29 | Correct | 29 ms | 596 KB | Output is correct |
30 | Correct | 209 ms | 344 KB | Output is correct |
31 | Correct | 207 ms | 340 KB | Output is correct |
32 | Correct | 209 ms | 344 KB | Output is correct |
33 | Correct | 285 ms | 600 KB | Output is correct |
34 | Correct | 320 ms | 340 KB | Output is correct |
35 | Correct | 330 ms | 468 KB | Output is correct |
36 | Correct | 749 ms | 852 KB | Output is correct |
37 | Correct | 817 ms | 684 KB | Output is correct |
38 | Correct | 890 ms | 992 KB | Output is correct |
39 | Correct | 809 ms | 944 KB | Output is correct |
40 | Correct | 861 ms | 1172 KB | Output is correct |
41 | Correct | 821 ms | 744 KB | Output is correct |
42 | Correct | 860 ms | 992 KB | Output is correct |
43 | Correct | 902 ms | 1408 KB | Output is correct |
44 | Correct | 892 ms | 1044 KB | Output is correct |
45 | Correct | 8 ms | 344 KB | Output is correct |
46 | Correct | 9 ms | 344 KB | Output is correct |
47 | Correct | 29 ms | 344 KB | Output is correct |
48 | Correct | 29 ms | 344 KB | Output is correct |
49 | Correct | 25 ms | 344 KB | Output is correct |
50 | Correct | 226 ms | 344 KB | Output is correct |
51 | Correct | 204 ms | 452 KB | Output is correct |
52 | Correct | 192 ms | 600 KB | Output is correct |
53 | Correct | 320 ms | 340 KB | Output is correct |
54 | Correct | 299 ms | 848 KB | Output is correct |
55 | Correct | 301 ms | 464 KB | Output is correct |
56 | Correct | 853 ms | 1272 KB | Output is correct |
57 | Correct | 833 ms | 1024 KB | Output is correct |
58 | Correct | 850 ms | 980 KB | Output is correct |
59 | Correct | 816 ms | 1156 KB | Output is correct |
60 | Correct | 838 ms | 948 KB | Output is correct |
61 | Correct | 740 ms | 936 KB | Output is correct |
62 | Correct | 793 ms | 552 KB | Output is correct |
63 | Correct | 710 ms | 928 KB | Output is correct |
64 | Correct | 781 ms | 948 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 9 ms | 344 KB | Output is correct |
2 | Correct | 20 ms | 344 KB | Output is correct |
3 | Partially correct | 143 ms | 344 KB | Output is partially correct |
4 | Partially correct | 425 ms | 456 KB | Output is partially correct |
5 | Partially correct | 855 ms | 676 KB | Output is partially correct |
6 | Incorrect | 0 ms | 344 KB | Incorrect |
7 | Halted | 0 ms | 0 KB | - |