# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
842074 | 2023-09-02T11:13:15 Z | Tenis0206 | 가장 긴 여행 (IOI23_longesttrip) | C++17 | 817 ms | 2232 KB |
#include <bits/stdc++.h> #include "longesttrip.h" using namespace std; const int nmax = 256; int n; std::vector<int> G[nmax + 5]; int d[nmax + 5]; bool sel[nmax + 5]; int t[nmax + 5]; int split, l1, l2; int find_next_go(int nod) { for(auto it : G[nod]) { if(!sel[it]) { return it; } } return -1; } void dfs(int nod) { sel[nod] = true; int son = find_next_go(nod); int nr_sons = 0; while(son!=-1) { t[son] = nod; dfs(son); son = find_next_go(nod); ++nr_sons; } if(nr_sons==2) { split = nod; } if(!nr_sons) { if(l1==-1) { l1 = nod; } else { l2 = nod; } } } std::vector<int> solve_component(int root) { split = -1, l1 = -1, l2 = -1; dfs(root); vector<int> r; if(l2==-1) { int nod = l1; r.push_back(l1); while(nod!=root) { nod = t[nod]; r.push_back(nod); } return r; } vector<int> a,b; bool ok = false; for(auto it : G[l1]) { if(it==root) { ok = true; } } if(!ok) { swap(l1,l2); } int nod = l1; while(nod!=split) { a.push_back(nod); nod = t[nod]; } reverse(a.begin(),a.end()); nod = l2; b.push_back(nod); while(nod!=root) { nod = t[nod]; b.push_back(nod); } reverse(b.begin(),b.end()); for(auto it : a) { r.push_back(it); } for(auto it : b) { r.push_back(it); } return r; } std::vector<int> longest_trip(int N, int D) { n = N; for(int i=0; i<n; i++) { G[i].clear(); sel[i] = false; t[i] = -1; } 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); } } } vector<int> r; for(int i=0; i<n; i++) { if(sel[i]) { continue; } vector<int> aux = solve_component(i); if(aux.size() > r.size()) { r = aux; } } return r; }
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 344 KB | Output is correct |
2 | Correct | 177 ms | 1680 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 7 ms | 344 KB | Output is correct |
2 | Correct | 25 ms | 344 KB | Output is correct |
3 | Correct | 118 ms | 600 KB | Output is correct |
4 | Correct | 343 ms | 1376 KB | Output is correct |
5 | Correct | 749 ms | 1064 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 8 ms | 344 KB | Output is correct |
2 | Correct | 24 ms | 344 KB | Output is correct |
3 | Correct | 137 ms | 1112 KB | Output is correct |
4 | Correct | 373 ms | 1476 KB | Output is correct |
5 | Correct | 689 ms | 1144 KB | Output is correct |
6 | Correct | 7 ms | 344 KB | Output is correct |
7 | Correct | 20 ms | 344 KB | Output is correct |
8 | Correct | 131 ms | 1124 KB | Output is correct |
9 | Correct | 260 ms | 724 KB | Output is correct |
10 | Correct | 720 ms | 1188 KB | Output is correct |
11 | Correct | 706 ms | 1048 KB | Output is correct |
12 | Correct | 727 ms | 1372 KB | Output is correct |
13 | Correct | 719 ms | 1856 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 7 ms | 504 KB | Output is correct |
2 | Correct | 24 ms | 756 KB | Output is correct |
3 | Correct | 124 ms | 716 KB | Output is correct |
4 | Correct | 374 ms | 632 KB | Output is correct |
5 | Correct | 701 ms | 1732 KB | Output is correct |
6 | Correct | 7 ms | 344 KB | Output is correct |
7 | Correct | 24 ms | 344 KB | Output is correct |
8 | Correct | 117 ms | 1364 KB | Output is correct |
9 | Correct | 284 ms | 720 KB | Output is correct |
10 | Correct | 778 ms | 1388 KB | Output is correct |
11 | Correct | 764 ms | 1308 KB | Output is correct |
12 | Correct | 734 ms | 1232 KB | Output is correct |
13 | Correct | 724 ms | 1420 KB | Output is correct |
14 | Correct | 7 ms | 344 KB | Output is correct |
15 | Correct | 12 ms | 344 KB | Output is correct |
16 | Correct | 44 ms | 504 KB | Output is correct |
17 | Correct | 72 ms | 600 KB | Output is correct |
18 | Correct | 128 ms | 856 KB | Output is correct |
19 | Correct | 283 ms | 1112 KB | Output is correct |
20 | Correct | 265 ms | 1368 KB | Output is correct |
21 | Correct | 743 ms | 1904 KB | Output is correct |
22 | Correct | 692 ms | 1664 KB | Output is correct |
23 | Correct | 709 ms | 1320 KB | Output is correct |
24 | Correct | 661 ms | 1516 KB | Output is correct |
25 | Correct | 12 ms | 344 KB | Output is correct |
26 | Correct | 9 ms | 344 KB | Output is correct |
27 | Correct | 21 ms | 344 KB | Output is correct |
28 | Correct | 20 ms | 344 KB | Output is correct |
29 | Correct | 21 ms | 344 KB | Output is correct |
30 | Correct | 166 ms | 960 KB | Output is correct |
31 | Correct | 153 ms | 968 KB | Output is correct |
32 | Correct | 174 ms | 856 KB | Output is correct |
33 | Correct | 285 ms | 1112 KB | Output is correct |
34 | Correct | 304 ms | 960 KB | Output is correct |
35 | Correct | 241 ms | 716 KB | Output is correct |
36 | Correct | 678 ms | 876 KB | Output is correct |
37 | Correct | 730 ms | 1208 KB | Output is correct |
38 | Correct | 764 ms | 1588 KB | Output is correct |
39 | Correct | 795 ms | 1604 KB | Output is correct |
40 | Correct | 730 ms | 1660 KB | Output is correct |
41 | Correct | 726 ms | 1016 KB | Output is correct |
42 | Correct | 772 ms | 1216 KB | Output is correct |
43 | Correct | 739 ms | 1628 KB | Output is correct |
44 | Correct | 674 ms | 1256 KB | Output is correct |
45 | Correct | 9 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 | 23 ms | 344 KB | Output is correct |
49 | Correct | 23 ms | 344 KB | Output is correct |
50 | Correct | 174 ms | 1212 KB | Output is correct |
51 | Correct | 190 ms | 952 KB | Output is correct |
52 | Correct | 160 ms | 704 KB | Output is correct |
53 | Correct | 293 ms | 1120 KB | Output is correct |
54 | Correct | 258 ms | 728 KB | Output is correct |
55 | Correct | 279 ms | 1376 KB | Output is correct |
56 | Correct | 769 ms | 1284 KB | Output is correct |
57 | Correct | 754 ms | 1496 KB | Output is correct |
58 | Correct | 743 ms | 1216 KB | Output is correct |
59 | Correct | 778 ms | 1556 KB | Output is correct |
60 | Correct | 747 ms | 1596 KB | Output is correct |
61 | Correct | 756 ms | 1260 KB | Output is correct |
62 | Correct | 747 ms | 1488 KB | Output is correct |
63 | Correct | 697 ms | 1424 KB | Output is correct |
64 | Correct | 716 ms | 1540 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 7 ms | 344 KB | Output is correct |
2 | Correct | 22 ms | 344 KB | Output is correct |
3 | Partially correct | 128 ms | 856 KB | Output is partially correct |
4 | Partially correct | 350 ms | 972 KB | Output is partially correct |
5 | Partially correct | 759 ms | 1784 KB | Output is partially correct |
6 | Correct | 6 ms | 344 KB | Output is correct |
7 | Correct | 21 ms | 344 KB | Output is correct |
8 | Partially correct | 129 ms | 600 KB | Output is partially correct |
9 | Partially correct | 296 ms | 968 KB | Output is partially correct |
10 | Partially correct | 717 ms | 1632 KB | Output is partially correct |
11 | Partially correct | 750 ms | 1652 KB | Output is partially correct |
12 | Partially correct | 721 ms | 1868 KB | Output is partially correct |
13 | Partially correct | 718 ms | 1892 KB | Output is partially correct |
14 | Correct | 7 ms | 344 KB | Output is correct |
15 | Correct | 12 ms | 344 KB | Output is correct |
16 | Correct | 41 ms | 344 KB | Output is correct |
17 | Partially correct | 78 ms | 444 KB | Output is partially correct |
18 | Partially correct | 137 ms | 868 KB | Output is partially correct |
19 | Partially correct | 267 ms | 600 KB | Output is partially correct |
20 | Partially correct | 295 ms | 856 KB | Output is partially correct |
21 | Correct | 10 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 | 25 ms | 344 KB | Output is correct |
25 | Correct | 17 ms | 344 KB | Output is correct |
26 | Partially correct | 153 ms | 716 KB | Output is partially correct |
27 | Partially correct | 176 ms | 708 KB | Output is partially correct |
28 | Partially correct | 164 ms | 444 KB | Output is partially correct |
29 | Partially correct | 276 ms | 856 KB | Output is partially correct |
30 | Partially correct | 252 ms | 1104 KB | Output is partially correct |
31 | Partially correct | 285 ms | 976 KB | Output is partially correct |
32 | Correct | 9 ms | 344 KB | Output is correct |
33 | Correct | 9 ms | 344 KB | Output is correct |
34 | Correct | 25 ms | 344 KB | Output is correct |
35 | Correct | 21 ms | 344 KB | Output is correct |
36 | Correct | 28 ms | 344 KB | Output is correct |
37 | Partially correct | 170 ms | 952 KB | Output is partially correct |
38 | Partially correct | 162 ms | 956 KB | Output is partially correct |
39 | Partially correct | 163 ms | 696 KB | Output is partially correct |
40 | Partially correct | 245 ms | 1220 KB | Output is partially correct |
41 | Partially correct | 274 ms | 1112 KB | Output is partially correct |
42 | Partially correct | 270 ms | 952 KB | Output is partially correct |
43 | Partially correct | 735 ms | 2232 KB | Output is partially correct |
44 | Partially correct | 696 ms | 1664 KB | Output is partially correct |
45 | Partially correct | 737 ms | 1696 KB | Output is partially correct |
46 | Partially correct | 729 ms | 1320 KB | Output is partially correct |
47 | Partially correct | 766 ms | 1036 KB | Output is partially correct |
48 | Partially correct | 781 ms | 1044 KB | Output is partially correct |
49 | Partially correct | 732 ms | 1776 KB | Output is partially correct |
50 | Partially correct | 740 ms | 1112 KB | Output is partially correct |
51 | Partially correct | 661 ms | 1484 KB | Output is partially correct |
52 | Partially correct | 667 ms | 992 KB | Output is partially correct |
53 | Partially correct | 765 ms | 1272 KB | Output is partially correct |
54 | Partially correct | 749 ms | 1452 KB | Output is partially correct |
55 | Partially correct | 727 ms | 1436 KB | Output is partially correct |
56 | Partially correct | 700 ms | 1456 KB | Output is partially correct |
57 | Partially correct | 676 ms | 1728 KB | Output is partially correct |
58 | Partially correct | 761 ms | 1444 KB | Output is partially correct |
59 | Partially correct | 711 ms | 1636 KB | Output is partially correct |
60 | Partially correct | 718 ms | 1292 KB | Output is partially correct |
61 | Partially correct | 739 ms | 1496 KB | Output is partially correct |
62 | Partially correct | 770 ms | 1104 KB | Output is partially correct |
63 | Partially correct | 817 ms | 1128 KB | Output is partially correct |
64 | Partially correct | 747 ms | 1832 KB | Output is partially correct |
65 | Partially correct | 739 ms | 1484 KB | Output is partially correct |
66 | Partially correct | 720 ms | 1312 KB | Output is partially correct |
67 | Partially correct | 700 ms | 1284 KB | Output is partially correct |
68 | Partially correct | 703 ms | 1112 KB | Output is partially correct |
69 | Partially correct | 710 ms | 1820 KB | Output is partially correct |
70 | Partially correct | 672 ms | 1992 KB | Output is partially correct |
71 | Partially correct | 659 ms | 1364 KB | Output is partially correct |
72 | Partially correct | 703 ms | 1540 KB | Output is partially correct |
73 | Partially correct | 705 ms | 1800 KB | Output is partially correct |
74 | Partially correct | 648 ms | 1700 KB | Output is partially correct |
75 | Partially correct | 624 ms | 856 KB | Output is partially correct |
76 | Partially correct | 685 ms | 864 KB | Output is partially correct |
77 | Partially correct | 710 ms | 1388 KB | Output is partially correct |
78 | Partially correct | 733 ms | 1800 KB | Output is partially correct |
79 | Partially correct | 714 ms | 1564 KB | Output is partially correct |
80 | Partially correct | 715 ms | 1568 KB | Output is partially correct |
81 | Partially correct | 709 ms | 1004 KB | Output is partially correct |
82 | Partially correct | 677 ms | 1528 KB | Output is partially correct |