# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1014281 | 2024-07-04T15:57:04 Z | JakobZorz | Longest Trip (IOI23_longesttrip) | C++17 | 873 ms | 1680 KB |
#include"longesttrip.h" #include<iostream> using namespace std; int n; vector<int>nodes[500]; vector<int>longest_trip(int N,int D){ n=N; for(int i=0;i<n;i++) nodes[i].clear(); for(int i=0;i<n;i++){ for(int j=i+1;j<n;j++){ if(are_connected({i},{j})){ nodes[i].push_back(j); nodes[j].push_back(i); //cout<<"CONN "<<i<<" "<<j<<"\n"; } } } vector<int>res={0}; vector<bool>vis(n); vis[0]=true; while(true){ int node=res.back(); //cout<<"VIS "<<node<<"\n"; for(int ne:nodes[node]) if(!vis[ne]){ res.push_back(ne); break; } vis[res.back()]=true; if(node==res.back()) break; } // all unvisited are strongly connected for(int i=0;i<(int)res.size();i++){ for(int ne:nodes[res[i]]){ if(!vis[ne]){ vector<int>res2; for(int j=0;j<n;j++) if(!vis[j]&&j!=ne) res2.push_back(j); res2.push_back(ne); for(int j=i;j<(int)res.size();j++) res2.push_back(res[j]); for(int j=0;j<i;j++) res2.push_back(res[j]); return res2; } } } vector<int>res2; for(int j=0;j<n;j++) if(!vis[j]) res2.push_back(j); if(res.size()>res2.size()) return res; else return res2; }
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 344 KB | Output is correct |
2 | Correct | 186 ms | 1348 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 5 ms | 344 KB | Output is correct |
2 | Correct | 17 ms | 344 KB | Output is correct |
3 | Correct | 148 ms | 344 KB | Output is correct |
4 | Correct | 369 ms | 484 KB | Output is correct |
5 | Correct | 805 ms | 700 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 | 468 KB | Output is correct |
4 | Correct | 399 ms | 724 KB | Output is correct |
5 | Correct | 758 ms | 956 KB | Output is correct |
6 | Correct | 7 ms | 344 KB | Output is correct |
7 | Correct | 21 ms | 344 KB | Output is correct |
8 | Correct | 148 ms | 460 KB | Output is correct |
9 | Correct | 300 ms | 600 KB | Output is correct |
10 | Correct | 819 ms | 964 KB | Output is correct |
11 | Correct | 796 ms | 1156 KB | Output is correct |
12 | Correct | 739 ms | 1076 KB | Output is correct |
13 | Correct | 738 ms | 868 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 5 ms | 344 KB | Output is correct |
2 | Correct | 32 ms | 348 KB | Output is correct |
3 | Correct | 138 ms | 344 KB | Output is correct |
4 | Correct | 323 ms | 448 KB | Output is correct |
5 | Correct | 657 ms | 796 KB | Output is correct |
6 | Correct | 6 ms | 344 KB | Output is correct |
7 | Correct | 25 ms | 344 KB | Output is correct |
8 | Correct | 126 ms | 344 KB | Output is correct |
9 | Correct | 272 ms | 472 KB | Output is correct |
10 | Correct | 673 ms | 624 KB | Output is correct |
11 | Correct | 706 ms | 896 KB | Output is correct |
12 | Correct | 713 ms | 796 KB | Output is correct |
13 | Correct | 751 ms | 896 KB | Output is correct |
14 | Correct | 7 ms | 356 KB | Output is correct |
15 | Correct | 11 ms | 344 KB | Output is correct |
16 | Correct | 47 ms | 444 KB | Output is correct |
17 | Correct | 80 ms | 344 KB | Output is correct |
18 | Correct | 171 ms | 456 KB | Output is correct |
19 | Correct | 306 ms | 708 KB | Output is correct |
20 | Correct | 308 ms | 884 KB | Output is correct |
21 | Correct | 866 ms | 968 KB | Output is correct |
22 | Correct | 773 ms | 1160 KB | Output is correct |
23 | Correct | 791 ms | 1136 KB | Output is correct |
24 | Correct | 787 ms | 1268 KB | Output is correct |
25 | Correct | 11 ms | 344 KB | Output is correct |
26 | Correct | 12 ms | 344 KB | Output is correct |
27 | Correct | 25 ms | 344 KB | Output is correct |
28 | Correct | 25 ms | 344 KB | Output is correct |
29 | Correct | 21 ms | 344 KB | Output is correct |
30 | Correct | 185 ms | 344 KB | Output is correct |
31 | Correct | 226 ms | 696 KB | Output is correct |
32 | Correct | 181 ms | 344 KB | Output is correct |
33 | Correct | 287 ms | 716 KB | Output is correct |
34 | Correct | 302 ms | 344 KB | Output is correct |
35 | Correct | 304 ms | 476 KB | Output is correct |
36 | Correct | 868 ms | 1124 KB | Output is correct |
37 | Correct | 864 ms | 1028 KB | Output is correct |
38 | Correct | 864 ms | 1160 KB | Output is correct |
39 | Correct | 822 ms | 1004 KB | Output is correct |
40 | Correct | 750 ms | 1208 KB | Output is correct |
41 | Correct | 762 ms | 740 KB | Output is correct |
42 | Correct | 755 ms | 1532 KB | Output is correct |
43 | Correct | 802 ms | 1020 KB | Output is correct |
44 | Correct | 817 ms | 1412 KB | Output is correct |
45 | Correct | 10 ms | 344 KB | Output is correct |
46 | Correct | 9 ms | 344 KB | Output is correct |
47 | Correct | 32 ms | 344 KB | Output is correct |
48 | Correct | 26 ms | 344 KB | Output is correct |
49 | Correct | 20 ms | 344 KB | Output is correct |
50 | Correct | 204 ms | 344 KB | Output is correct |
51 | Correct | 168 ms | 344 KB | Output is correct |
52 | Correct | 188 ms | 344 KB | Output is correct |
53 | Correct | 296 ms | 344 KB | Output is correct |
54 | Correct | 265 ms | 724 KB | Output is correct |
55 | Correct | 301 ms | 480 KB | Output is correct |
56 | Correct | 771 ms | 1296 KB | Output is correct |
57 | Correct | 788 ms | 1148 KB | Output is correct |
58 | Correct | 813 ms | 940 KB | Output is correct |
59 | Correct | 755 ms | 1460 KB | Output is correct |
60 | Correct | 807 ms | 1108 KB | Output is correct |
61 | Correct | 734 ms | 572 KB | Output is correct |
62 | Correct | 834 ms | 948 KB | Output is correct |
63 | Correct | 782 ms | 1464 KB | Output is correct |
64 | Correct | 752 ms | 1184 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 6 ms | 344 KB | Output is correct |
2 | Correct | 32 ms | 344 KB | Output is correct |
3 | Partially correct | 135 ms | 344 KB | Output is partially correct |
4 | Partially correct | 398 ms | 344 KB | Output is partially correct |
5 | Partially correct | 766 ms | 1108 KB | Output is partially correct |
6 | Correct | 5 ms | 344 KB | Output is correct |
7 | Correct | 27 ms | 344 KB | Output is correct |
8 | Partially correct | 143 ms | 464 KB | Output is partially correct |
9 | Partially correct | 307 ms | 600 KB | Output is partially correct |
10 | Partially correct | 778 ms | 1048 KB | Output is partially correct |
11 | Partially correct | 831 ms | 1128 KB | Output is partially correct |
12 | Partially correct | 809 ms | 792 KB | Output is partially correct |
13 | Partially correct | 797 ms | 592 KB | Output is partially correct |
14 | Correct | 5 ms | 340 KB | Output is correct |
15 | Correct | 12 ms | 344 KB | Output is correct |
16 | Correct | 34 ms | 344 KB | Output is correct |
17 | Partially correct | 99 ms | 344 KB | Output is partially correct |
18 | Partially correct | 141 ms | 456 KB | Output is partially correct |
19 | Partially correct | 273 ms | 344 KB | Output is partially correct |
20 | Partially correct | 320 ms | 600 KB | Output is partially correct |
21 | Correct | 8 ms | 344 KB | Output is correct |
22 | Correct | 8 ms | 344 KB | Output is correct |
23 | Correct | 22 ms | 344 KB | Output is correct |
24 | Correct | 20 ms | 344 KB | Output is correct |
25 | Correct | 22 ms | 344 KB | Output is correct |
26 | Partially correct | 209 ms | 344 KB | Output is partially correct |
27 | Partially correct | 199 ms | 456 KB | Output is partially correct |
28 | Partially correct | 177 ms | 448 KB | Output is partially correct |
29 | Partially correct | 318 ms | 592 KB | Output is partially correct |
30 | Partially correct | 306 ms | 600 KB | Output is partially correct |
31 | Partially correct | 314 ms | 464 KB | Output is partially correct |
32 | Correct | 9 ms | 344 KB | Output is correct |
33 | Correct | 10 ms | 344 KB | Output is correct |
34 | Correct | 29 ms | 344 KB | Output is correct |
35 | Correct | 27 ms | 344 KB | Output is correct |
36 | Correct | 26 ms | 344 KB | Output is correct |
37 | Partially correct | 183 ms | 344 KB | Output is partially correct |
38 | Partially correct | 176 ms | 596 KB | Output is partially correct |
39 | Partially correct | 196 ms | 344 KB | Output is partially correct |
40 | Partially correct | 257 ms | 468 KB | Output is partially correct |
41 | Partially correct | 299 ms | 592 KB | Output is partially correct |
42 | Partially correct | 295 ms | 480 KB | Output is partially correct |
43 | Partially correct | 847 ms | 1000 KB | Output is partially correct |
44 | Partially correct | 833 ms | 980 KB | Output is partially correct |
45 | Partially correct | 812 ms | 1284 KB | Output is partially correct |
46 | Partially correct | 830 ms | 1152 KB | Output is partially correct |
47 | Partially correct | 722 ms | 944 KB | Output is partially correct |
48 | Partially correct | 825 ms | 756 KB | Output is partially correct |
49 | Partially correct | 742 ms | 968 KB | Output is partially correct |
50 | Partially correct | 682 ms | 928 KB | Output is partially correct |
51 | Partially correct | 751 ms | 872 KB | Output is partially correct |
52 | Partially correct | 773 ms | 776 KB | Output is partially correct |
53 | Partially correct | 757 ms | 732 KB | Output is partially correct |
54 | Partially correct | 773 ms | 908 KB | Output is partially correct |
55 | Partially correct | 701 ms | 1156 KB | Output is partially correct |
56 | Partially correct | 739 ms | 876 KB | Output is partially correct |
57 | Partially correct | 825 ms | 928 KB | Output is partially correct |
58 | Partially correct | 719 ms | 1080 KB | Output is partially correct |
59 | Partially correct | 661 ms | 1064 KB | Output is partially correct |
60 | Partially correct | 754 ms | 1000 KB | Output is partially correct |
61 | Partially correct | 771 ms | 752 KB | Output is partially correct |
62 | Partially correct | 745 ms | 1004 KB | Output is partially correct |
63 | Partially correct | 813 ms | 956 KB | Output is partially correct |
64 | Partially correct | 813 ms | 1176 KB | Output is partially correct |
65 | Partially correct | 800 ms | 1444 KB | Output is partially correct |
66 | Partially correct | 824 ms | 1192 KB | Output is partially correct |
67 | Partially correct | 789 ms | 848 KB | Output is partially correct |
68 | Partially correct | 787 ms | 592 KB | Output is partially correct |
69 | Partially correct | 791 ms | 1212 KB | Output is partially correct |
70 | Partially correct | 827 ms | 1296 KB | Output is partially correct |
71 | Partially correct | 784 ms | 1348 KB | Output is partially correct |
72 | Partially correct | 827 ms | 1108 KB | Output is partially correct |
73 | Partially correct | 841 ms | 1208 KB | Output is partially correct |
74 | Partially correct | 792 ms | 1220 KB | Output is partially correct |
75 | Partially correct | 809 ms | 988 KB | Output is partially correct |
76 | Partially correct | 873 ms | 484 KB | Output is partially correct |
77 | Partially correct | 754 ms | 808 KB | Output is partially correct |
78 | Partially correct | 794 ms | 1680 KB | Output is partially correct |
79 | Partially correct | 749 ms | 1340 KB | Output is partially correct |
80 | Partially correct | 739 ms | 1428 KB | Output is partially correct |
81 | Partially correct | 808 ms | 568 KB | Output is partially correct |
82 | Partially correct | 851 ms | 1292 KB | Output is partially correct |