Submission #986932

# Submission time Handle Problem Language Result Execution time Memory
986932 2024-05-21T15:21:12 Z activedeltorre Longest Trip (IOI23_longesttrip) C++17
5 / 100
7 ms 676 KB
#include "longesttrip.h"
#include <deque>
#include <vector>
using namespace std;
deque<int>dq;
int fre[100005];
vector<int> longest_trip(int N, int D)
{
    int i,n=N,capst,capdr;
    vector<int>ans,pl1,pl2;
    pl1.push_back(1);
    pl2.push_back(0);
    if(are_connected(pl1,pl2)==1)
    {
        dq.push_front(0);
        dq.push_back(1);
        capst=0;
        capdr=1;
        fre[0]++;
        fre[1]++;
    }
    else
    {
        dq.push_front(0);
        dq.push_back(2);
        capst=0;
        capdr=2;
        fre[0]++;
        fre[2]++;
    }
    for(i=1;i<n;i++)
    {
        if(fre[i]==0)
        {
            pl1.clear();
            pl2.clear();
            pl1.push_back(capst);
            pl2.push_back(i);
            if(are_connected(pl1,pl2))
            {
                capst=i;
                dq.push_front(i);
            }
            else
            {
                capdr=i;
                dq.push_back(i);
            }
        }
    }
    while(dq.size())
    {
        ans.push_back(dq.front());
        dq.pop_front();
    }
    return ans;
}

Compilation message

longesttrip.cpp: In function 'std::vector<int> longest_trip(int, int)':
longesttrip.cpp:9:21: warning: variable 'capdr' set but not used [-Wunused-but-set-variable]
    9 |     int i,n=N,capst,capdr;
      |                     ^~~~~
# 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 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 5 ms 600 KB Output is correct
# 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 5 ms 344 KB Output is correct
4 Correct 4 ms 344 KB Output is correct
5 Correct 5 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 6 ms 344 KB Output is correct
2 Correct 6 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 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 5 ms 600 KB Output is correct
10 Correct 5 ms 676 KB Output is correct
11 Correct 5 ms 600 KB Output is correct
12 Correct 4 ms 432 KB Output is correct
13 Correct 5 ms 608 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 5 ms 344 KB Output is correct
3 Correct 5 ms 344 KB Output is correct
4 Correct 5 ms 428 KB Output is correct
5 Correct 5 ms 600 KB Output is correct
6 Incorrect 0 ms 344 KB Incorrect
7 Halted 0 ms 0 KB -