# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1065127 | 2024-08-18T23:47:44 Z | vjudge1 | Longest Trip (IOI23_longesttrip) | C++17 | 902 ms | 1420 KB |
#include "longesttrip.h" #include<bits/stdc++.h> using namespace std; vector<int>adj[256]; bitset<256>vis; void dfs(int n){ if(vis[n])return; vis[n]=1; for(auto i:adj[n]) dfs(i); } vector<int>path; void dfs2(int n){ path.push_back(n); vis[n]=1; for(auto i:adj[n]) if(!vis[i]) return dfs2(i); } vector<int> longest_trip(int N, int D){ for(int i=0;i<N;i++) adj[i].clear(); for(int i=1;i<N;i++) for(int j=i;j--;) if(are_connected({i},{j})) adj[i].push_back(j), adj[j].push_back(i); vis.reset(); dfs(0); if(vis.count()!=N){ vector<int>a,b; for(int i=0;i<N;i++) if(!vis[i]) a.push_back(i); else b.push_back(i); return a.size()>b.size()?a:b; } for(int i=0;i<N;i++) { vis.reset(); path.clear(); dfs2(i); if(path.size()==N) return path; for(auto x:adj[i]) if(!vis[x]) { vector<int>v2; vis[x]=1; for(int i=0;i<N;i++) if(!vis[i])v2.push_back(i); v2.push_back(x); for(auto i:path) v2.push_back(i); return v2; } } vector<int>b; for(int i=0;i<N;i++) if(!vis[i]) b.push_back(i); return path.size()>b.size()?path:b; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 344 KB | Output is correct |
2 | Correct | 166 ms | 828 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 7 ms | 344 KB | Output is correct |
2 | Correct | 22 ms | 344 KB | Output is correct |
3 | Correct | 161 ms | 344 KB | Output is correct |
4 | Correct | 407 ms | 716 KB | Output is correct |
5 | Correct | 842 ms | 592 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 7 ms | 344 KB | Output is correct |
2 | Correct | 21 ms | 344 KB | Output is correct |
3 | Correct | 150 ms | 344 KB | Output is correct |
4 | Correct | 413 ms | 480 KB | Output is correct |
5 | Correct | 826 ms | 1100 KB | Output is correct |
6 | Correct | 7 ms | 344 KB | Output is correct |
7 | Correct | 21 ms | 344 KB | Output is correct |
8 | Correct | 155 ms | 344 KB | Output is correct |
9 | Correct | 288 ms | 460 KB | Output is correct |
10 | Correct | 850 ms | 964 KB | Output is correct |
11 | Correct | 828 ms | 1408 KB | Output is correct |
12 | Correct | 871 ms | 1124 KB | Output is correct |
13 | Correct | 818 ms | 1204 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 7 ms | 344 KB | Output is correct |
2 | Correct | 21 ms | 344 KB | Output is correct |
3 | Correct | 156 ms | 344 KB | Output is correct |
4 | Correct | 437 ms | 588 KB | Output is correct |
5 | Correct | 839 ms | 1120 KB | Output is correct |
6 | Correct | 11 ms | 344 KB | Output is correct |
7 | Correct | 24 ms | 344 KB | Output is correct |
8 | Correct | 154 ms | 344 KB | Output is correct |
9 | Correct | 303 ms | 460 KB | Output is correct |
10 | Correct | 804 ms | 848 KB | Output is correct |
11 | Correct | 830 ms | 1212 KB | Output is correct |
12 | Correct | 822 ms | 704 KB | Output is correct |
13 | Correct | 873 ms | 1104 KB | Output is correct |
14 | Correct | 7 ms | 344 KB | Output is correct |
15 | Correct | 12 ms | 344 KB | Output is correct |
16 | Correct | 34 ms | 344 KB | Output is correct |
17 | Correct | 89 ms | 344 KB | Output is correct |
18 | Correct | 155 ms | 436 KB | Output is correct |
19 | Correct | 304 ms | 456 KB | Output is correct |
20 | Correct | 298 ms | 456 KB | Output is correct |
21 | Correct | 844 ms | 1420 KB | Output is correct |
22 | Correct | 843 ms | 1016 KB | Output is correct |
23 | Correct | 879 ms | 848 KB | Output is correct |
24 | Correct | 883 ms | 1268 KB | Output is correct |
25 | Correct | 7 ms | 344 KB | Output is correct |
26 | Correct | 8 ms | 344 KB | Output is correct |
27 | Correct | 28 ms | 344 KB | Output is correct |
28 | Correct | 19 ms | 344 KB | Output is correct |
29 | Correct | 22 ms | 340 KB | Output is correct |
30 | Correct | 230 ms | 600 KB | Output is correct |
31 | Correct | 228 ms | 436 KB | Output is correct |
32 | Correct | 217 ms | 344 KB | Output is correct |
33 | Correct | 324 ms | 700 KB | Output is correct |
34 | Correct | 308 ms | 344 KB | Output is correct |
35 | Correct | 280 ms | 600 KB | Output is correct |
36 | Correct | 850 ms | 1360 KB | Output is correct |
37 | Correct | 812 ms | 1200 KB | Output is correct |
38 | Correct | 831 ms | 704 KB | Output is correct |
39 | Correct | 825 ms | 1172 KB | Output is correct |
40 | Correct | 891 ms | 996 KB | Output is correct |
41 | Correct | 890 ms | 804 KB | Output is correct |
42 | Correct | 863 ms | 984 KB | Output is correct |
43 | Correct | 781 ms | 1156 KB | Output is correct |
44 | Correct | 814 ms | 772 KB | Output is correct |
45 | Correct | 8 ms | 344 KB | Output is correct |
46 | Correct | 7 ms | 344 KB | Output is correct |
47 | Correct | 16 ms | 344 KB | Output is correct |
48 | Correct | 23 ms | 344 KB | Output is correct |
49 | Correct | 24 ms | 344 KB | Output is correct |
50 | Correct | 195 ms | 600 KB | Output is correct |
51 | Correct | 204 ms | 600 KB | Output is correct |
52 | Correct | 191 ms | 600 KB | Output is correct |
53 | Correct | 309 ms | 344 KB | Output is correct |
54 | Correct | 324 ms | 596 KB | Output is correct |
55 | Correct | 284 ms | 476 KB | Output is correct |
56 | Correct | 902 ms | 788 KB | Output is correct |
57 | Correct | 842 ms | 756 KB | Output is correct |
58 | Correct | 807 ms | 1092 KB | Output is correct |
59 | Correct | 818 ms | 916 KB | Output is correct |
60 | Correct | 779 ms | 1164 KB | Output is correct |
61 | Correct | 862 ms | 548 KB | Output is correct |
62 | Correct | 799 ms | 852 KB | Output is correct |
63 | Correct | 850 ms | 960 KB | Output is correct |
64 | Correct | 842 ms | 812 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 6 ms | 344 KB | Output is correct |
2 | Correct | 25 ms | 344 KB | Output is correct |
3 | Partially correct | 121 ms | 344 KB | Output is partially correct |
4 | Partially correct | 388 ms | 464 KB | Output is partially correct |
5 | Partially correct | 827 ms | 732 KB | Output is partially correct |
6 | Correct | 12 ms | 344 KB | Output is correct |
7 | Correct | 22 ms | 344 KB | Output is correct |
8 | Partially correct | 151 ms | 344 KB | Output is partially correct |
9 | Partially correct | 317 ms | 600 KB | Output is partially correct |
10 | Partially correct | 863 ms | 948 KB | Output is partially correct |
11 | Partially correct | 837 ms | 848 KB | Output is partially correct |
12 | Partially correct | 879 ms | 992 KB | Output is partially correct |
13 | Partially correct | 844 ms | 720 KB | Output is partially correct |
14 | Correct | 5 ms | 340 KB | Output is correct |
15 | Correct | 11 ms | 344 KB | Output is correct |
16 | Correct | 38 ms | 344 KB | Output is correct |
17 | Partially correct | 100 ms | 344 KB | Output is partially correct |
18 | Partially correct | 152 ms | 344 KB | Output is partially correct |
19 | Partially correct | 325 ms | 700 KB | Output is partially correct |
20 | Partially correct | 320 ms | 712 KB | Output is partially correct |
21 | Correct | 8 ms | 344 KB | Output is correct |
22 | Correct | 9 ms | 344 KB | Output is correct |
23 | Correct | 22 ms | 344 KB | Output is correct |
24 | Correct | 19 ms | 344 KB | Output is correct |
25 | Correct | 25 ms | 344 KB | Output is correct |
26 | Partially correct | 233 ms | 344 KB | Output is partially correct |
27 | Partially correct | 193 ms | 344 KB | Output is partially correct |
28 | Partially correct | 190 ms | 344 KB | Output is partially correct |
29 | Partially correct | 333 ms | 440 KB | Output is partially correct |
30 | Partially correct | 343 ms | 460 KB | Output is partially correct |
31 | Partially correct | 295 ms | 344 KB | Output is partially correct |
32 | Correct | 6 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 | 30 ms | 344 KB | Output is correct |
36 | Correct | 33 ms | 344 KB | Output is correct |
37 | Partially correct | 205 ms | 460 KB | Output is partially correct |
38 | Partially correct | 206 ms | 600 KB | Output is partially correct |
39 | Partially correct | 188 ms | 344 KB | Output is partially correct |
40 | Partially correct | 317 ms | 600 KB | Output is partially correct |
41 | Partially correct | 281 ms | 344 KB | Output is partially correct |
42 | Partially correct | 308 ms | 592 KB | Output is partially correct |
43 | Partially correct | 778 ms | 1144 KB | Output is partially correct |
44 | Partially correct | 833 ms | 900 KB | Output is partially correct |
45 | Partially correct | 801 ms | 848 KB | Output is partially correct |
46 | Partially correct | 850 ms | 1136 KB | Output is partially correct |
47 | Partially correct | 828 ms | 896 KB | Output is partially correct |
48 | Partially correct | 810 ms | 1168 KB | Output is partially correct |
49 | Partially correct | 891 ms | 908 KB | Output is partially correct |
50 | Partially correct | 825 ms | 1216 KB | Output is partially correct |
51 | Partially correct | 855 ms | 1000 KB | Output is partially correct |
52 | Partially correct | 781 ms | 1260 KB | Output is partially correct |
53 | Partially correct | 890 ms | 1032 KB | Output is partially correct |
54 | Partially correct | 864 ms | 1208 KB | Output is partially correct |
55 | Partially correct | 882 ms | 848 KB | Output is partially correct |
56 | Partially correct | 810 ms | 940 KB | Output is partially correct |
57 | Partially correct | 803 ms | 1044 KB | Output is partially correct |
58 | Partially correct | 824 ms | 1232 KB | Output is partially correct |
59 | Partially correct | 824 ms | 784 KB | Output is partially correct |
60 | Partially correct | 817 ms | 848 KB | Output is partially correct |
61 | Partially correct | 816 ms | 796 KB | Output is partially correct |
62 | Partially correct | 822 ms | 1252 KB | Output is partially correct |
63 | Partially correct | 813 ms | 1136 KB | Output is partially correct |
64 | Partially correct | 818 ms | 1128 KB | Output is partially correct |
65 | Partially correct | 805 ms | 960 KB | Output is partially correct |
66 | Partially correct | 839 ms | 908 KB | Output is partially correct |
67 | Partially correct | 830 ms | 872 KB | Output is partially correct |
68 | Partially correct | 847 ms | 808 KB | Output is partially correct |
69 | Partially correct | 835 ms | 956 KB | Output is partially correct |
70 | Partially correct | 835 ms | 1156 KB | Output is partially correct |
71 | Partially correct | 826 ms | 868 KB | Output is partially correct |
72 | Partially correct | 812 ms | 932 KB | Output is partially correct |
73 | Partially correct | 792 ms | 1068 KB | Output is partially correct |
74 | Partially correct | 864 ms | 1080 KB | Output is partially correct |
75 | Partially correct | 798 ms | 776 KB | Output is partially correct |
76 | Partially correct | 806 ms | 1104 KB | Output is partially correct |
77 | Partially correct | 894 ms | 1204 KB | Output is partially correct |
78 | Partially correct | 793 ms | 1184 KB | Output is partially correct |
79 | Partially correct | 833 ms | 1268 KB | Output is partially correct |
80 | Partially correct | 881 ms | 944 KB | Output is partially correct |
81 | Partially correct | 840 ms | 1108 KB | Output is partially correct |
82 | Partially correct | 878 ms | 1104 KB | Output is partially correct |