# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
841183 | 2023-09-01T10:36:27 Z | NicolaAbusaad2014 | 가장 긴 여행 (IOI23_longesttrip) | C++17 | 90 ms | 440 KB |
#include "longesttrip.h" #include <bits/stdc++.h> using namespace std; void split(vector<int>&v,int sz,vector<int>&a,vector<int>&b) { for(int i=0;i<sz;i++){ a.push_back(v[i]); } for(int i=sz;i<v.size();i++){ b.push_back(v[i]); } } void BS(vector<int>A,vector<int>B,int&s,int&e) { while(A.size()>1){ vector<int>a,b; split(A,(A.size())/2,a,b); if(are_connected(a,B)){ swap(A,a); } else{ swap(A,b); } } while(B.size()>1){ vector<int>a,b; split(B,(B.size())/2,a,b); if(are_connected(A,a)){ swap(B,a); } else{ swap(B,b); } } s=A[0]; e=B[0]; } std::vector<int> longest_trip(int N, int D) { vector<int>path(1); vector<bool>vis(N); vis[0]=true; while(path.size()<N){ int a=path.front(); int b=path.back(); int c,d; vector<int>rest; for(int i=0;i<N;i++){ if(!vis[i]){ rest.push_back(i); } } if(are_connected(vector<int>(1,a),rest)){ BS(vector<int>(1,a),rest,c,d); path.insert(path.begin(),d); vis[d]=true; continue; } if(are_connected(vector<int>(1,b),rest)){ BS(vector<int>(1,b),rest,c,d); path.push_back(d); vis[d]=true; continue; } if(!are_connected(path,rest)){ if(path.size()>=rest.size()){ return path; } return rest; } BS(path,rest,c,d); for(int i=0;i<path.size();i++){ if(path[i]==c){ c=i; break; } } for(int i=0;i<rest.size();i++){ if(rest[i]==d){ d=i; break; } } vector<int>ans; for(int i=c+1;i<path.size();i++){ ans.push_back(path[i]); } for(int i=0;i<=c;i++){ ans.push_back(path[i]); } for(int i=d;i<rest.size();i++){ ans.push_back(rest[i]); } for(int i=0;i<d;i++){ ans.push_back(rest[i]); } return ans; } return path; }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 208 KB | Output is correct |
2 | Correct | 18 ms | 208 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 9 ms | 208 KB | Output is correct |
2 | Correct | 18 ms | 208 KB | Output is correct |
3 | Correct | 46 ms | 208 KB | Output is correct |
4 | Correct | 68 ms | 312 KB | Output is correct |
5 | Correct | 85 ms | 336 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 10 ms | 208 KB | Output is correct |
2 | Correct | 23 ms | 208 KB | Output is correct |
3 | Correct | 42 ms | 296 KB | Output is correct |
4 | Correct | 38 ms | 304 KB | Output is correct |
5 | Correct | 81 ms | 324 KB | Output is correct |
6 | Correct | 10 ms | 208 KB | Output is correct |
7 | Correct | 19 ms | 208 KB | Output is correct |
8 | Correct | 50 ms | 208 KB | Output is correct |
9 | Correct | 65 ms | 208 KB | Output is correct |
10 | Correct | 86 ms | 336 KB | Output is correct |
11 | Correct | 74 ms | 208 KB | Output is correct |
12 | Correct | 58 ms | 312 KB | Output is correct |
13 | Correct | 80 ms | 320 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 13 ms | 208 KB | Output is correct |
2 | Correct | 23 ms | 208 KB | Output is correct |
3 | Correct | 49 ms | 208 KB | Output is correct |
4 | Correct | 52 ms | 312 KB | Output is correct |
5 | Correct | 88 ms | 208 KB | Output is correct |
6 | Correct | 15 ms | 208 KB | Output is correct |
7 | Correct | 23 ms | 208 KB | Output is correct |
8 | Correct | 48 ms | 208 KB | Output is correct |
9 | Correct | 46 ms | 304 KB | Output is correct |
10 | Correct | 66 ms | 208 KB | Output is correct |
11 | Correct | 77 ms | 312 KB | Output is correct |
12 | Correct | 71 ms | 208 KB | Output is correct |
13 | Correct | 72 ms | 208 KB | Output is correct |
14 | Correct | 12 ms | 208 KB | Output is correct |
15 | Correct | 8 ms | 208 KB | Output is correct |
16 | Correct | 32 ms | 208 KB | Output is correct |
17 | Correct | 33 ms | 208 KB | Output is correct |
18 | Correct | 44 ms | 300 KB | Output is correct |
19 | Correct | 55 ms | 208 KB | Output is correct |
20 | Correct | 59 ms | 208 KB | Output is correct |
21 | Correct | 86 ms | 320 KB | Output is correct |
22 | Correct | 69 ms | 324 KB | Output is correct |
23 | Correct | 86 ms | 316 KB | Output is correct |
24 | Correct | 90 ms | 312 KB | Output is correct |
25 | Correct | 10 ms | 208 KB | Output is correct |
26 | Correct | 14 ms | 208 KB | Output is correct |
27 | Correct | 18 ms | 208 KB | Output is correct |
28 | Correct | 23 ms | 208 KB | Output is correct |
29 | Correct | 19 ms | 208 KB | Output is correct |
30 | Correct | 39 ms | 208 KB | Output is correct |
31 | Correct | 34 ms | 208 KB | Output is correct |
32 | Correct | 25 ms | 208 KB | Output is correct |
33 | Correct | 42 ms | 208 KB | Output is correct |
34 | Correct | 53 ms | 208 KB | Output is correct |
35 | Correct | 43 ms | 208 KB | Output is correct |
36 | Correct | 87 ms | 208 KB | Output is correct |
37 | Correct | 84 ms | 320 KB | Output is correct |
38 | Correct | 81 ms | 208 KB | Output is correct |
39 | Correct | 70 ms | 324 KB | Output is correct |
40 | Correct | 59 ms | 208 KB | Output is correct |
41 | Correct | 42 ms | 336 KB | Output is correct |
42 | Correct | 41 ms | 312 KB | Output is correct |
43 | Correct | 52 ms | 336 KB | Output is correct |
44 | Correct | 48 ms | 376 KB | Output is correct |
45 | Correct | 9 ms | 208 KB | Output is correct |
46 | Correct | 12 ms | 208 KB | Output is correct |
47 | Correct | 22 ms | 208 KB | Output is correct |
48 | Correct | 29 ms | 208 KB | Output is correct |
49 | Correct | 26 ms | 208 KB | Output is correct |
50 | Correct | 48 ms | 208 KB | Output is correct |
51 | Correct | 34 ms | 208 KB | Output is correct |
52 | Correct | 40 ms | 208 KB | Output is correct |
53 | Correct | 48 ms | 208 KB | Output is correct |
54 | Correct | 47 ms | 308 KB | Output is correct |
55 | Correct | 43 ms | 208 KB | Output is correct |
56 | Correct | 75 ms | 316 KB | Output is correct |
57 | Correct | 83 ms | 320 KB | Output is correct |
58 | Correct | 69 ms | 316 KB | Output is correct |
59 | Correct | 59 ms | 320 KB | Output is correct |
60 | Correct | 72 ms | 316 KB | Output is correct |
61 | Correct | 48 ms | 208 KB | Output is correct |
62 | Correct | 78 ms | 316 KB | Output is correct |
63 | Correct | 60 ms | 208 KB | Output is correct |
64 | Correct | 54 ms | 316 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 10 ms | 208 KB | Output is correct |
2 | Correct | 23 ms | 208 KB | Output is correct |
3 | Correct | 40 ms | 208 KB | Output is correct |
4 | Partially correct | 53 ms | 208 KB | Output is partially correct |
5 | Partially correct | 71 ms | 316 KB | Output is partially correct |
6 | Correct | 14 ms | 208 KB | Output is correct |
7 | Correct | 21 ms | 208 KB | Output is correct |
8 | Correct | 26 ms | 208 KB | Output is correct |
9 | Partially correct | 55 ms | 208 KB | Output is partially correct |
10 | Partially correct | 86 ms | 308 KB | Output is partially correct |
11 | Partially correct | 73 ms | 304 KB | Output is partially correct |
12 | Partially correct | 66 ms | 208 KB | Output is partially correct |
13 | Partially correct | 71 ms | 208 KB | Output is partially correct |
14 | Correct | 10 ms | 208 KB | Output is correct |
15 | Correct | 12 ms | 208 KB | Output is correct |
16 | Correct | 22 ms | 208 KB | Output is correct |
17 | Correct | 34 ms | 208 KB | Output is correct |
18 | Correct | 38 ms | 256 KB | Output is correct |
19 | Partially correct | 49 ms | 208 KB | Output is partially correct |
20 | Partially correct | 57 ms | 208 KB | Output is partially correct |
21 | Correct | 16 ms | 208 KB | Output is correct |
22 | Correct | 16 ms | 208 KB | Output is correct |
23 | Correct | 20 ms | 208 KB | Output is correct |
24 | Correct | 16 ms | 208 KB | Output is correct |
25 | Correct | 17 ms | 208 KB | Output is correct |
26 | Correct | 49 ms | 208 KB | Output is correct |
27 | Correct | 23 ms | 296 KB | Output is correct |
28 | Correct | 26 ms | 208 KB | Output is correct |
29 | Partially correct | 36 ms | 308 KB | Output is partially correct |
30 | Partially correct | 43 ms | 208 KB | Output is partially correct |
31 | Partially correct | 47 ms | 208 KB | Output is partially correct |
32 | Correct | 12 ms | 208 KB | Output is correct |
33 | Correct | 17 ms | 208 KB | Output is correct |
34 | Correct | 29 ms | 208 KB | Output is correct |
35 | Correct | 27 ms | 208 KB | Output is correct |
36 | Correct | 13 ms | 208 KB | Output is correct |
37 | Correct | 47 ms | 208 KB | Output is correct |
38 | Correct | 34 ms | 208 KB | Output is correct |
39 | Correct | 42 ms | 208 KB | Output is correct |
40 | Partially correct | 48 ms | 208 KB | Output is partially correct |
41 | Partially correct | 51 ms | 208 KB | Output is partially correct |
42 | Partially correct | 50 ms | 208 KB | Output is partially correct |
43 | Partially correct | 63 ms | 436 KB | Output is partially correct |
44 | Partially correct | 79 ms | 308 KB | Output is partially correct |
45 | Partially correct | 72 ms | 208 KB | Output is partially correct |
46 | Partially correct | 68 ms | 208 KB | Output is partially correct |
47 | Partially correct | 53 ms | 320 KB | Output is partially correct |
48 | Partially correct | 74 ms | 208 KB | Output is partially correct |
49 | Partially correct | 62 ms | 328 KB | Output is partially correct |
50 | Partially correct | 50 ms | 308 KB | Output is partially correct |
51 | Partially correct | 53 ms | 208 KB | Output is partially correct |
52 | Partially correct | 52 ms | 328 KB | Output is partially correct |
53 | Partially correct | 46 ms | 208 KB | Output is partially correct |
54 | Partially correct | 58 ms | 328 KB | Output is partially correct |
55 | Partially correct | 39 ms | 208 KB | Output is partially correct |
56 | Partially correct | 84 ms | 208 KB | Output is partially correct |
57 | Partially correct | 56 ms | 336 KB | Output is partially correct |
58 | Partially correct | 56 ms | 324 KB | Output is partially correct |
59 | Partially correct | 40 ms | 308 KB | Output is partially correct |
60 | Partially correct | 53 ms | 308 KB | Output is partially correct |
61 | Partially correct | 53 ms | 208 KB | Output is partially correct |
62 | Partially correct | 69 ms | 328 KB | Output is partially correct |
63 | Partially correct | 62 ms | 324 KB | Output is partially correct |
64 | Partially correct | 60 ms | 312 KB | Output is partially correct |
65 | Partially correct | 77 ms | 320 KB | Output is partially correct |
66 | Partially correct | 47 ms | 440 KB | Output is partially correct |
67 | Partially correct | 56 ms | 340 KB | Output is partially correct |
68 | Partially correct | 85 ms | 436 KB | Output is partially correct |
69 | Partially correct | 62 ms | 312 KB | Output is partially correct |
70 | Partially correct | 62 ms | 332 KB | Output is partially correct |
71 | Partially correct | 71 ms | 316 KB | Output is partially correct |
72 | Partially correct | 65 ms | 316 KB | Output is partially correct |
73 | Partially correct | 55 ms | 324 KB | Output is partially correct |
74 | Partially correct | 50 ms | 208 KB | Output is partially correct |
75 | Partially correct | 60 ms | 312 KB | Output is partially correct |
76 | Partially correct | 37 ms | 356 KB | Output is partially correct |
77 | Partially correct | 72 ms | 208 KB | Output is partially correct |
78 | Partially correct | 43 ms | 336 KB | Output is partially correct |
79 | Partially correct | 69 ms | 312 KB | Output is partially correct |
80 | Partially correct | 64 ms | 336 KB | Output is partially correct |
81 | Partially correct | 67 ms | 316 KB | Output is partially correct |
82 | Partially correct | 66 ms | 316 KB | Output is partially correct |