// hola soy Dember :D
// 31/03/2024
#include "longesttrip.h"
#include <bits/stdc++.h>
#define ll int
#define pll pair<ll,ll>
#define F first
#define S second
#define Z size()
#define pb push_back
#define bp pop_back
#define fo(x,y,z) for(ll x=y; x<=z; x++)
#define of(x,y,z) for(ll x=y; x>=z; x--)
#define all(n) n.begin(), n.end()
#define arr(x,y,z) x+y, x+y+z
using namespace std;
ll n, k, xd, zd;
vector<ll> a,b, ans, vac;
pair<vector<ll>, vector<ll>> c1, c2;
vector<int> longest_trip(int N, int D){
n=N; k=D;a.pb(0);
fo(i,1,n){
c1.F=c1.S=c2.F=c1.F=vac;
while(!b.empty()){
c2.F.pb(a.back());
c2.S.pb(b.back());
if(are_connected(c2.F,c2.S))
while(!b.empty()){a.pb(b.back());b.bp();}
}
c1.F.pb(a.back());
c1.S.pb(i);
if(are_connected(c1.F,c1.S))a.pb(i);
else b.pb(i);
}
ans=((a.size()>b.size())?a:b);
return ans;
}
/*int main()
{
cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);
int t=1, m;
cin>>t>>m;
vector<ll> v=longest_trip(t,m);
for(auto u:v)cout<<u<<' ';cout<<"\n";
return 0;
}*/
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
344 KB |
invalid array |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
344 KB |
invalid array |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
344 KB |
invalid array |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
344 KB |
invalid array |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
344 KB |
invalid array |
2 |
Halted |
0 ms |
0 KB |
- |