Submission #1006997

#TimeUsernameProblemLanguageResultExecution timeMemory
1006997De3b0o가장 긴 여행 (IOI23_longesttrip)C++17
15 / 100
7 ms596 KiB
#include "longesttrip.h"
#include<bits/stdc++.h>
#include<random>
#define ll long long
#define F first
#define S second
#define in insert
#define pb push_back
#define ppb pop_back()
#define d3 ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define cans cout << ans << "\n";
#define yes cout << "Yes" << "\n";
#define no cout << "No" << "\n";
#define pll pair<ll,ll>
#define lin cout << "\n";
#define sqr 340
#define mod 1000000007
#define mid ((l+r)/2)
#define lc (2*n)
#define rc (2*n+1)

using namespace std;

std::vector<int> longest_trip(int N, int D)
{
    ll n = N;
    vector<int> trnbo;
    trnbo.pb(0);
    ll x = -1;
    for(int i = 0 ; n-1>i ; i++)
    {
        if(are_connected({i},{i+1}))
            trnbo.pb(i+1);
        else
        {
            if(i==n-2)
                x=i+1;
            else if(i==n-3)
            {
                trnbo.pb(i+2);
                trnbo.pb(i+1);
                break;
            }
            else
            {
                trnbo.pb(i+2);
                trnbo.pb(i+1);
                trnbo.pb(i+3);
                i+=2;
            }
        }
    }
    if(x!=-1)
        trnbo.insert(trnbo.begin(),x);
    return trnbo;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...