답안 #960120

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
960120 2024-04-09T16:58:08 Z tutis 가장 긴 여행 (IOI23_longesttrip) C++17
5 / 100
11 ms 600 KB
#include "longesttrip.h"
#include <bits/stdc++.h>
using namespace std;
mt19937_64 rng(0);

std::vector<int> longest_trip(int N, int D)
{
    vector<int>x,y;
    x.push_back(0);
    for(int i=1;i<N;i++){
        if(are_connected({0}, {i})){
            x.push_back(i);
        } else{
            y.push_back(i);
        }
    }
    if(y.size()>0 && !are_connected(x,y)){
        if(x.size()>y.size()){
            return x;
        } else{
            return y;
        }
    }
    if(y.empty()){
        vector<int>ans;
        vector<int>p;
        ans.push_back({1});
        for(int i=2;i<N;i++){
            p.push_back(i);
        }
        while(!p.empty()){
            shuffle(p.begin(),p.end(),rng);
            bool found=false;
            for(int i: p){
                if(are_connected({ans.back()}, {i})){
                    ans.push_back(i);
                    p.erase(find(p.begin(),p.end(), i));
                    found=true;
                    break;
                }
            }
            if(!found){
                break;
            }
        }
        ans.push_back(0);
        for(int i: p){
            ans.push_back(i);
        }
        return ans;
    }
}

Compilation message

longesttrip.cpp: In function 'std::vector<int> longest_trip(int, int)':
longesttrip.cpp:8:16: warning: control reaches end of non-void function [-Wreturn-type]
    8 |     vector<int>x,y;
      |                ^
# 결과 실행 시간 메모리 Grader output
1 Runtime error 1 ms 344 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 7 ms 344 KB Output is correct
2 Correct 9 ms 344 KB Output is correct
3 Correct 9 ms 344 KB Output is correct
4 Correct 11 ms 344 KB Output is correct
5 Correct 10 ms 344 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 8 ms 344 KB Output is correct
2 Correct 9 ms 344 KB Output is correct
3 Correct 9 ms 344 KB Output is correct
4 Correct 10 ms 344 KB Output is correct
5 Correct 9 ms 344 KB Output is correct
6 Runtime error 1 ms 344 KB Execution killed with signal 11
7 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 7 ms 596 KB Output is correct
2 Correct 8 ms 340 KB Output is correct
3 Correct 8 ms 344 KB Output is correct
4 Correct 11 ms 348 KB Output is correct
5 Correct 11 ms 600 KB Output is correct
6 Runtime error 1 ms 344 KB Execution killed with signal 11
7 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 7 ms 344 KB Output is correct
2 Correct 11 ms 344 KB Output is correct
3 Correct 10 ms 344 KB Output is correct
4 Correct 10 ms 344 KB Output is correct
5 Partially correct 11 ms 344 KB Output is partially correct
6 Runtime error 1 ms 344 KB Execution killed with signal 11
7 Halted 0 ms 0 KB -