Submission #1038935

# Submission time Handle Problem Language Result Execution time Memory
1038935 2024-07-30T09:37:17 Z ZanP Longest Trip (IOI23_longesttrip) C++17
5 / 100
9 ms 420 KB
#include "longesttrip.h"
#include <iostream>
#include <vector>
using namespace std;

void sub1(vector<int> & ans, int n){
    ans.resize(n);
    for(int i = 0;i<n;i++){ans[i] = i;}
}

void sub2(vector<int> & ans, int n){
    ans.reserve(n);
    ans.push_back(0);
    if(!are_connected({n-2}, {n-1})){ans.push_back(n-1);} 
    for(int i = 0;i<n-1;i++){
        if(are_connected({i}, {i+1})){
            ans.push_back(i+1);
        }else{
            if(i == n-2){break;}
            ans.push_back(i+2);
            ans.push_back(i+1);
            if(i != n-3)ans.push_back(i+3);
            i+=2;
        }
    }
}

vector<int> longest_trip(int n, int d){
    vector<int> ans; 
    if(d == 3){
        sub1(ans, n);
        return ans;
    }
    if(d == 2){
        sub2(ans,n);
        return ans;
    }
    return {0, 4, 5 ,2};
}
# 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 Correct 1 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 0 ms 344 KB Output is correct
5 Correct 0 ms 344 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 9 ms 344 KB Output is correct
2 Correct 5 ms 344 KB Output is correct
3 Correct 6 ms 420 KB Output is correct
4 Correct 5 ms 344 KB Output is correct
5 Correct 7 ms 344 KB Output is correct
6 Incorrect 0 ms 344 KB Incorrect
7 Halted 0 ms 0 KB -
# 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 Incorrect
2 Halted 0 ms 0 KB -