Submission #1063941

# Submission time Handle Problem Language Result Execution time Memory
1063941 2024-08-18T06:25:54 Z parsadox2 Longest Trip (IOI23_longesttrip) C++17
15 / 100
69 ms 860 KB
#include "longesttrip.h"
#include <bits/stdc++.h>

using namespace std;

const int N = 256;
int n , d;
bool in_path[N];

vector <int> maximal()
{
    for(int i = 0 ; i < n ; i++)
        in_path[i] = false;
    vector <int> vec;
    vec.push_back(0);
    in_path[0] = true;
    while(vec.size() < n)
    {
        vector <int> A; A.push_back(vec.back());
        vector <int> B;
        for(int i = 0 ; i < n ; i++)  if(!in_path[i])
            B.push_back(i);
        if(!are_connected(A , B))
            break;
        int low = 0 , high = B.size();
        while(high - low > 1)
        {
            int mid = (low + high) >> 1;
            vector <int> tmp;
            for(int i = low ; i < mid ; i++)
                tmp.push_back(B[i]);
            if(are_connected(A , tmp))
                high = mid;
            else
                low = mid;
        }
        in_path[B[low]] = true;
        vec.push_back(B[low]);
    }
    reverse(vec.begin() , vec.end());
    while(vec.size() < n)
    {
        vector <int> A;  A.push_back(vec.back());
        vector <int> B;
        for(int i = 0 ; i < n ; i++)  if(!in_path[i])
            B.push_back(i);
        if(!are_connected(A , B))
            break;
        int low = 0 , high = B.size();
        while(high - low > 1)
        {
            int mid = (low + high) >> 1;
            vector <int> tmp;
            for(int i = low ; i < mid ; i++)
                tmp.push_back(B[i]);
            if(are_connected(A , tmp))
                high = mid;
            else
                low = mid;
        }
        in_path[B[low]] = true;
        vec.push_back(B[low]);
    }
    return vec;
}

vector<int> longest_trip(int nn, int dd)
{
    n = nn;
    d = dd;
    vector <int> vec = maximal();
    return vec;
}

Compilation message

longesttrip.cpp: In function 'std::vector<int> maximal()':
longesttrip.cpp:17:22: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   17 |     while(vec.size() < n)
      |           ~~~~~~~~~~~^~~
longesttrip.cpp:41:22: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   41 |     while(vec.size() < n)
      |           ~~~~~~~~~~~^~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 11 ms 344 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 344 KB Output is correct
2 Correct 13 ms 344 KB Output is correct
3 Correct 29 ms 344 KB Output is correct
4 Correct 50 ms 344 KB Output is correct
5 Correct 54 ms 344 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 6 ms 344 KB Output is correct
2 Correct 13 ms 344 KB Output is correct
3 Correct 29 ms 344 KB Output is correct
4 Correct 36 ms 344 KB Output is correct
5 Correct 69 ms 344 KB Output is correct
6 Correct 5 ms 344 KB Output is correct
7 Correct 14 ms 344 KB Output is correct
8 Correct 31 ms 344 KB Output is correct
9 Correct 33 ms 344 KB Output is correct
10 Correct 67 ms 344 KB Output is correct
11 Correct 57 ms 600 KB Output is correct
12 Correct 54 ms 344 KB Output is correct
13 Correct 52 ms 344 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 7 ms 344 KB Output is correct
2 Correct 14 ms 344 KB Output is correct
3 Correct 34 ms 344 KB Output is correct
4 Correct 39 ms 344 KB Output is correct
5 Correct 61 ms 860 KB Output is correct
6 Correct 7 ms 344 KB Output is correct
7 Correct 11 ms 344 KB Output is correct
8 Correct 21 ms 344 KB Output is correct
9 Correct 49 ms 344 KB Output is correct
10 Correct 48 ms 600 KB Output is correct
11 Correct 64 ms 344 KB Output is correct
12 Correct 58 ms 344 KB Output is correct
13 Correct 52 ms 344 KB Output is correct
14 Correct 5 ms 344 KB Output is correct
15 Incorrect 1 ms 344 KB Incorrect
16 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 4 ms 344 KB Output is correct
2 Correct 13 ms 344 KB Output is correct
3 Correct 29 ms 344 KB Output is correct
4 Partially correct 35 ms 344 KB Output is partially correct
5 Partially correct 50 ms 344 KB Output is partially correct
6 Correct 7 ms 344 KB Output is correct
7 Correct 13 ms 344 KB Output is correct
8 Correct 23 ms 344 KB Output is correct
9 Partially correct 38 ms 344 KB Output is partially correct
10 Partially correct 66 ms 456 KB Output is partially correct
11 Partially correct 59 ms 344 KB Output is partially correct
12 Partially correct 52 ms 344 KB Output is partially correct
13 Partially correct 51 ms 344 KB Output is partially correct
14 Incorrect 1 ms 344 KB Incorrect
15 Halted 0 ms 0 KB -