Submission #854267

# Submission time Handle Problem Language Result Execution time Memory
854267 2023-09-26T14:58:37 Z Ludissey Longest Trip (IOI23_longesttrip) C++17
5 / 100
7 ms 600 KB
#include <bits/stdc++.h>
#include "longesttrip.h"
using namespace std;

std::vector<int> longest_trip(int n, int d)
{
    vector<int> A;
    vector<int> B;
    A.push_back(0);
    for (int i = 1; i < n; i++)
    {
        if(are_connected({i}, {A[0]})) A.push_back(i);
        else if(B.size()==0 || are_connected({i}, {B[0]})) B.push_back(i);
        else {
            for (int x = 0; x < B.size(); x++) A.insert(A.begin(), (B[x]));
            B.clear();
        }
    }
    if(A.size()<B.size()) swap(A,B);
    return A;
}

Compilation message

longesttrip.cpp: In function 'std::vector<int> longest_trip(int, int)':
longesttrip.cpp:15:31: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   15 |             for (int x = 0; x < B.size(); x++) A.insert(A.begin(), (B[x]));
      |                             ~~^~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Incorrect 1 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 5 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 5 ms 344 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 6 ms 344 KB Output is correct
2 Correct 4 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 Incorrect 0 ms 344 KB Incorrect
7 Halted 0 ms 0 KB -
# 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 Incorrect 1 ms 344 KB Incorrect
7 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 5 ms 344 KB Output is correct
2 Correct 5 ms 344 KB Output is correct
3 Correct 5 ms 344 KB Output is correct
4 Correct 5 ms 344 KB Output is correct
5 Correct 6 ms 544 KB Output is correct
6 Incorrect 0 ms 344 KB Incorrect
7 Halted 0 ms 0 KB -