답안 #986934

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
986934 2024-05-21T15:25:23 Z activedeltorre 가장 긴 여행 (IOI23_longesttrip) C++17
5 / 100
7 ms 600 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)==1)
            {
                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;
      |                     ^~~~~
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 344 KB Incorrect
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 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 5 ms 600 KB Output is correct
# 결과 실행 시간 메모리 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
6 Incorrect 0 ms 344 KB Incorrect
7 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 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 344 KB Output is correct
6 Correct 4 ms 344 KB Output is correct
7 Correct 4 ms 344 KB Output is correct
8 Correct 5 ms 344 KB Output is correct
9 Correct 4 ms 344 KB Output is correct
10 Correct 6 ms 600 KB Output is correct
11 Correct 5 ms 344 KB Output is correct
12 Correct 5 ms 600 KB Output is correct
13 Correct 4 ms 344 KB Output is correct
14 Incorrect 0 ms 596 KB Incorrect
15 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 6 ms 344 KB Output is correct
2 Correct 7 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
6 Incorrect 1 ms 344 KB Incorrect
7 Halted 0 ms 0 KB -