///~~~LOTA~~~///
#include "longesttrip.h"
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define append push_back
#define add insert
#define nl '\n'
#define ff first
#define ss second
#define pii pair<int,int>
#define pll pair<ll,ll>
#define all(x) (x).begin(),(x).end()
#define L0TA ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define terminator main
#define N 256
int nxt[N];
vector<int> solve1(int n){
int a,b,p,q,x,y,z;
a=b=0;p=q=1;
x=y=1;
for(int i=2;i<n;i++){
if(are_connected({b},{i})){
nxt[b]=i;
x++;
b=i;
}
else if(are_connected({i},{p})){
nxt[i]=p;
y++;
p=i;
}
else{
nxt[b]=p;
x+=y;
b=q;
y=1;
p=q=i;
}
}
if(x>y) z=a;
else z=p;
vector<int> v;
for(int i=0;i<max(x,y);i++){
v.append(z);
z=nxt[z];
}
return v;
}
vector<int> solve2(int n){
int p,q,r;
p=0;
q=1;
r=are_connected({0},{1});
if(r) nxt[0]=1;
else{
nxt[0]=2;
nxt[2]=1;
}
for(int i=3-r;i<n;i++){
if(are_connected({q},{i})){
nxt[q]=i;
q=i;
}
else{
nxt[i]=p;
p=i;
}
}
vector<int> v;
for(int i=0;i<n;i++){
v.append(p);
p=nxt[p];
}
return v;
}
vector<int> solve3(int n){
vector<int> v;
for(int i=0;i<n;i++)
v.append(i);
return v;
}
vector<int> longest_trip(int n,int d){
if(d==3) return solve3(n);
if(d==2) return solve2(n);
return solve1(n);
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
344 KB |
Incorrect |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
344 KB |
Output is correct |
2 |
Correct |
1 ms |
344 KB |
Output is correct |
3 |
Correct |
0 ms |
344 KB |
Output is correct |
4 |
Correct |
1 ms |
344 KB |
Output is correct |
5 |
Correct |
0 ms |
344 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
5 ms |
344 KB |
Output is correct |
2 |
Correct |
5 ms |
344 KB |
Output is correct |
3 |
Correct |
5 ms |
344 KB |
Output is correct |
4 |
Correct |
5 ms |
344 KB |
Output is correct |
5 |
Correct |
6 ms |
344 KB |
Output is correct |
6 |
Correct |
4 ms |
344 KB |
Output is correct |
7 |
Correct |
5 ms |
344 KB |
Output is correct |
8 |
Correct |
5 ms |
344 KB |
Output is correct |
9 |
Correct |
5 ms |
344 KB |
Output is correct |
10 |
Correct |
6 ms |
344 KB |
Output is correct |
11 |
Correct |
5 ms |
432 KB |
Output is correct |
12 |
Correct |
4 ms |
344 KB |
Output is correct |
13 |
Correct |
5 ms |
344 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
5 ms |
344 KB |
Output is correct |
2 |
Correct |
4 ms |
344 KB |
Output is correct |
3 |
Correct |
5 ms |
344 KB |
Output is correct |
4 |
Correct |
5 ms |
344 KB |
Output is correct |
5 |
Correct |
4 ms |
344 KB |
Output is correct |
6 |
Correct |
4 ms |
344 KB |
Output is correct |
7 |
Correct |
5 ms |
344 KB |
Output is correct |
8 |
Correct |
5 ms |
344 KB |
Output is correct |
9 |
Correct |
4 ms |
344 KB |
Output is correct |
10 |
Correct |
5 ms |
344 KB |
Output is correct |
11 |
Correct |
7 ms |
436 KB |
Output is correct |
12 |
Correct |
5 ms |
440 KB |
Output is correct |
13 |
Correct |
6 ms |
344 KB |
Output is correct |
14 |
Correct |
7 ms |
344 KB |
Output is correct |
15 |
Correct |
6 ms |
344 KB |
Output is correct |
16 |
Correct |
7 ms |
344 KB |
Output is correct |
17 |
Correct |
6 ms |
344 KB |
Output is correct |
18 |
Correct |
6 ms |
340 KB |
Output is correct |
19 |
Correct |
6 ms |
344 KB |
Output is correct |
20 |
Correct |
8 ms |
344 KB |
Output is correct |
21 |
Correct |
6 ms |
344 KB |
Output is correct |
22 |
Correct |
6 ms |
344 KB |
Output is correct |
23 |
Correct |
6 ms |
344 KB |
Output is correct |
24 |
Correct |
7 ms |
344 KB |
Output is correct |
25 |
Correct |
5 ms |
344 KB |
Output is correct |
26 |
Correct |
5 ms |
344 KB |
Output is correct |
27 |
Correct |
5 ms |
344 KB |
Output is correct |
28 |
Correct |
5 ms |
344 KB |
Output is correct |
29 |
Correct |
6 ms |
344 KB |
Output is correct |
30 |
Correct |
5 ms |
344 KB |
Output is correct |
31 |
Correct |
7 ms |
344 KB |
Output is correct |
32 |
Correct |
10 ms |
344 KB |
Output is correct |
33 |
Correct |
5 ms |
344 KB |
Output is correct |
34 |
Correct |
5 ms |
344 KB |
Output is correct |
35 |
Correct |
6 ms |
344 KB |
Output is correct |
36 |
Correct |
6 ms |
344 KB |
Output is correct |
37 |
Correct |
9 ms |
344 KB |
Output is correct |
38 |
Correct |
4 ms |
344 KB |
Output is correct |
39 |
Correct |
7 ms |
344 KB |
Output is correct |
40 |
Correct |
7 ms |
344 KB |
Output is correct |
41 |
Correct |
8 ms |
344 KB |
Output is correct |
42 |
Correct |
7 ms |
344 KB |
Output is correct |
43 |
Correct |
8 ms |
440 KB |
Output is correct |
44 |
Correct |
8 ms |
344 KB |
Output is correct |
45 |
Correct |
5 ms |
344 KB |
Output is correct |
46 |
Correct |
7 ms |
344 KB |
Output is correct |
47 |
Correct |
5 ms |
344 KB |
Output is correct |
48 |
Correct |
6 ms |
344 KB |
Output is correct |
49 |
Correct |
4 ms |
344 KB |
Output is correct |
50 |
Correct |
4 ms |
344 KB |
Output is correct |
51 |
Correct |
7 ms |
344 KB |
Output is correct |
52 |
Correct |
5 ms |
344 KB |
Output is correct |
53 |
Correct |
5 ms |
344 KB |
Output is correct |
54 |
Correct |
6 ms |
344 KB |
Output is correct |
55 |
Correct |
6 ms |
344 KB |
Output is correct |
56 |
Correct |
6 ms |
344 KB |
Output is correct |
57 |
Correct |
6 ms |
344 KB |
Output is correct |
58 |
Correct |
6 ms |
344 KB |
Output is correct |
59 |
Correct |
7 ms |
344 KB |
Output is correct |
60 |
Correct |
7 ms |
344 KB |
Output is correct |
61 |
Correct |
9 ms |
412 KB |
Output is correct |
62 |
Correct |
8 ms |
344 KB |
Output is correct |
63 |
Correct |
9 ms |
344 KB |
Output is correct |
64 |
Correct |
7 ms |
344 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
344 KB |
Incorrect |
2 |
Halted |
0 ms |
0 KB |
- |