Submission #979961

# Submission time Handle Problem Language Result Execution time Memory
979961 2024-05-11T17:41:01 Z vjudge1 Longest Trip (IOI23_longesttrip) C++17
15 / 100
7 ms 796 KB
#include "longesttrip.h"
using namespace std;
#define pb push_back
vector<int> longest_trip(int N, int D)
{
    vector<int> ans;
    vector<int> v1 (1);
    vector<int> v2(1);
    if(N==3){
        v1={0};
        v2={1};
        if(are_connected(v1,v2)){
            v1={1};
            v2={2};
            if(are_connected(v1,v2)){
                ans={0,1,2};
                return ans;
            }
            else{
                ans={1,0,2};
                return ans;
            }
        }
        else{
            ans={0,2,1};
            return ans;
        }
    }
    ans.pb(0);
    int last=0;
    for(int i=1; i<N-1; ++i){
        v1={last};
        v2={i};
        if(are_connected(v1,v2)){
            ans.pb(i);
            last=i;
        }
        else{
            i++;
            ans.pb(i);
            ans.pb(i-1);
            last=i-1;
        }
    }
    if(ans.size()!=N){
        v1={last};
        v2={N-1};
        if(are_connected(v1,v2)){
            ans.pb(N-1);
            last=N-1;
        }
        else{
        int a=ans[ans.size()-1];
        ans.pop_back();
        int b=ans[ans.size()-1];
        ans.pop_back();
        ans.pb(N-1);
        ans.pb(b);
        ans.pb(a);
        }
    }
    return ans;

}

Compilation message

longesttrip.cpp: In function 'std::vector<int> longest_trip(int, int)':
longesttrip.cpp:45:18: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   45 |     if(ans.size()!=N){
      |        ~~~~~~~~~~^~~
# 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 7 ms 344 KB Output is correct
2 Correct 4 ms 344 KB Output is correct
3 Correct 6 ms 344 KB Output is correct
4 Correct 5 ms 344 KB Output is correct
5 Correct 4 ms 600 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 344 KB Output is correct
2 Correct 4 ms 344 KB Output is correct
3 Correct 5 ms 344 KB Output is correct
4 Correct 4 ms 344 KB Output is correct
5 Correct 4 ms 344 KB Output is correct
6 Correct 4 ms 344 KB Output is correct
7 Correct 4 ms 344 KB Output is correct
8 Correct 5 ms 344 KB Output is correct
9 Correct 5 ms 344 KB Output is correct
10 Correct 5 ms 600 KB Output is correct
11 Correct 5 ms 344 KB Output is correct
12 Correct 4 ms 344 KB Output is correct
13 Correct 5 ms 600 KB Output is correct
# Verdict Execution time Memory 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 4 ms 344 KB Output is correct
5 Correct 4 ms 600 KB Output is correct
6 Correct 5 ms 344 KB Output is correct
7 Correct 5 ms 344 KB Output is correct
8 Correct 5 ms 344 KB Output is correct
9 Correct 5 ms 344 KB Output is correct
10 Correct 6 ms 600 KB Output is correct
11 Correct 4 ms 596 KB Output is correct
12 Correct 4 ms 344 KB Output is correct
13 Correct 4 ms 344 KB Output is correct
14 Incorrect 0 ms 344 KB Incorrect
15 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 6 ms 344 KB Output is correct
2 Correct 6 ms 344 KB Output is correct
3 Correct 5 ms 340 KB Output is correct
4 Correct 5 ms 340 KB Output is correct
5 Correct 5 ms 600 KB Output is correct
6 Correct 4 ms 344 KB Output is correct
7 Correct 4 ms 344 KB Output is correct
8 Correct 4 ms 344 KB Output is correct
9 Correct 4 ms 344 KB Output is correct
10 Correct 5 ms 608 KB Output is correct
11 Correct 6 ms 796 KB Output is correct
12 Correct 5 ms 344 KB Output is correct
13 Correct 4 ms 344 KB Output is correct
14 Incorrect 0 ms 344 KB Incorrect
15 Halted 0 ms 0 KB -