Submission #1069587

# Submission time Handle Problem Language Result Execution time Memory
1069587 2024-08-22T06:25:37 Z Sir_Ahmed_Imran Longest Trip (IOI23_longesttrip) C++17
5 / 100
2 ms 408 KB
                            ///~~~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});
    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);
}
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 344 KB invalid array
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 344 KB Output is correct
2 Correct 2 ms 356 KB Output is correct
3 Correct 0 ms 344 KB Output is correct
4 Correct 0 ms 408 KB Output is correct
5 Correct 0 ms 344 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 344 KB Incorrect
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 344 KB invalid array
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 344 KB invalid array
2 Halted 0 ms 0 KB -