답안 #839721

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
839721 2023-08-30T15:48:54 Z model_code 가장 긴 여행 (IOI23_longesttrip) C++17
15 / 100
13 ms 336 KB
// correct/solution-subtask2.cpp

#include "longesttrip.h"
#include <algorithm>
#include <random>
#include <deque>

std::vector<int> longest_trip(int N, int /*D*/)
{
    srand(time(0));
    std::vector<int> ids(N);
    for (int i = 0; i < N; i++)
        ids[i] = i;
    random_shuffle(ids.begin(), ids.end());

    std::deque<int> line;
    line.clear();

    if (!are_connected({ids[0]}, {ids[1]}))
    {
        std::swap(ids[0], ids[2]);
    }
    line.push_back(ids[0]);
    line.push_back(ids[1]);
    for (int i = 2; i < N; i++)
    {
        if (are_connected({ids[i]}, {line.back()}))
        {
            line.push_back(ids[i]);
        }
        else if (are_connected({ids[i]}, {line.front()}))
        {
            line.push_front(ids[i]);
        }
        else
        {
            break;
        }
    }
    std::vector<int> ans;
    ans.clear();
    for (int i : line)
        ans.push_back(i);
    return ans;
}
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 208 KB Incorrect
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 8 ms 208 KB Output is correct
2 Correct 6 ms 208 KB Output is correct
3 Correct 9 ms 208 KB Output is correct
4 Correct 6 ms 208 KB Output is correct
5 Correct 7 ms 288 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 10 ms 208 KB Output is correct
2 Correct 9 ms 208 KB Output is correct
3 Correct 6 ms 208 KB Output is correct
4 Correct 12 ms 336 KB Output is correct
5 Correct 7 ms 208 KB Output is correct
6 Correct 9 ms 208 KB Output is correct
7 Correct 8 ms 208 KB Output is correct
8 Correct 7 ms 208 KB Output is correct
9 Correct 4 ms 208 KB Output is correct
10 Correct 8 ms 208 KB Output is correct
11 Correct 5 ms 284 KB Output is correct
12 Correct 10 ms 288 KB Output is correct
13 Correct 9 ms 208 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 7 ms 208 KB Output is correct
2 Correct 11 ms 208 KB Output is correct
3 Correct 6 ms 208 KB Output is correct
4 Correct 6 ms 208 KB Output is correct
5 Correct 6 ms 208 KB Output is correct
6 Correct 10 ms 208 KB Output is correct
7 Correct 11 ms 208 KB Output is correct
8 Correct 9 ms 208 KB Output is correct
9 Correct 13 ms 208 KB Output is correct
10 Correct 9 ms 208 KB Output is correct
11 Correct 10 ms 256 KB Output is correct
12 Correct 10 ms 288 KB Output is correct
13 Correct 9 ms 208 KB Output is correct
14 Incorrect 0 ms 208 KB Incorrect
15 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 10 ms 208 KB Output is correct
2 Correct 6 ms 208 KB Output is correct
3 Correct 13 ms 208 KB Output is correct
4 Correct 8 ms 208 KB Output is correct
5 Correct 8 ms 208 KB Output is correct
6 Correct 8 ms 208 KB Output is correct
7 Correct 7 ms 208 KB Output is correct
8 Correct 6 ms 208 KB Output is correct
9 Correct 9 ms 208 KB Output is correct
10 Correct 6 ms 208 KB Output is correct
11 Correct 6 ms 208 KB Output is correct
12 Correct 8 ms 208 KB Output is correct
13 Correct 4 ms 208 KB Output is correct
14 Incorrect 0 ms 208 KB Incorrect
15 Halted 0 ms 0 KB -