# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
840429 | ogkostya | Longest Trip (IOI23_longesttrip) | C++17 | 12 ms | 336 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include "longesttrip.h"
std::vector<int> longest_trip(int N, int D)
{
std::vector<int> an1 = {};
std::vector<int> an2 = {};
an1.push_back(0);
std::vector<int> temp1 = {};
std::vector<int> temp2 = {};
for (int i = 1; i < N; i++)
{
temp1.clear();
temp1.push_back(i);
temp2.clear();
temp2.push_back(an1.back());
if (are_connected(temp1, temp2))
{
an1.push_back(i);
}
else
{
if (an2.size() == 0)
{
an2.push_back(i);
}
else
{
temp2.clear();
temp2.push_back(an2.back());
if (are_connected(temp1, temp2))
{
an2.push_back(i);
}
else
{
while (an2.size() > 0)
{
an1.push_back(an2.back());
an2.pop_back();
}
an2.push_back(i);
}
}
}
}
if (an2.size() > 0)
{
temp1.clear();
temp1.push_back(an1.back());
temp2.clear();
temp2.push_back(an2.back());
if (are_connected(temp1, temp2))
{
while (an2.size() > 0)
{
an1.push_back(an2.back());
an2.pop_back();
}
}
else
{
temp2.clear();
temp2.push_back(an2.front());
if (are_connected(temp1, temp2))
{
for (int i = 0; i < an2.size(); i++)
{
an1.push_back(an2[i]);
}
}
}
}
return an1;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |