답안 #1069591

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1069591 2024-08-22T06:27:22 Z Sir_Ahmed_Imran 가장 긴 여행 (IOI23_longesttrip) C++17
15 / 100
7 ms 596 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});
    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 invalid array
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 344 KB Output is correct
2 Correct 2 ms 344 KB Output is correct
3 Correct 1 ms 344 KB Output is correct
4 Correct 0 ms 344 KB Output is correct
5 Correct 1 ms 596 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 6 ms 344 KB Output is correct
2 Correct 6 ms 344 KB Output is correct
3 Correct 4 ms 344 KB Output is correct
4 Correct 7 ms 344 KB Output is correct
5 Correct 6 ms 344 KB Output is correct
6 Correct 5 ms 344 KB Output is correct
7 Correct 6 ms 344 KB Output is correct
8 Correct 4 ms 344 KB Output is correct
9 Correct 5 ms 344 KB Output is correct
10 Correct 6 ms 436 KB Output is correct
11 Correct 5 ms 344 KB Output is correct
12 Correct 5 ms 344 KB Output is correct
13 Correct 4 ms 344 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 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 -