답안 #1065234

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1065234 2024-08-19T04:00:41 Z LittleOrange 가장 긴 여행 (IOI23_longesttrip) C++17
5 / 100
1000 ms 692 KB
#include "longesttrip.h"

#include <vector>
#include<bits/stdc++.h>
using namespace std;
using ll = int;

std::vector<int> longest_trip(int N, int D)
{
    mt19937_64 mt(random_device{}());
    ll t0 = time(0);
    ll n = N;
    if (D==3){
        vector<ll> r(n);
        iota(r.begin(),r.end(),0);
        return r;
    }
    vector<vector<ll>> a(n,vector<ll>(n,0));
    for(ll i = 0;i<n;i++){
        for(ll j = i+1;j<n;j++){
            a[i][j] = a[j][i] = are_connected({i},{j});
        }
    }
    vector<ll> ret;
    vector<ll> ord(n);
    iota(ord.begin(),ord.end(),0);
    auto it = ord.begin();
    vector<ll> cur;
    cur.reserve(n);
    ll cnt = 1000000/n;
    while(cnt--){
        shuffle(ord.begin(),ord.end(),mt);
        cur.push_back(ord[0]);
        for(ll i : ord){
            if (a[cur.back()][i]) cur.push_back(i);
        }
        if(cur.size()>ret.size()) ret = cur;
        cur.clear();
    }
    return ret;
}

Compilation message

longesttrip.cpp: In function 'std::vector<int> longest_trip(int, int)':
longesttrip.cpp:11:8: warning: unused variable 't0' [-Wunused-variable]
   11 |     ll t0 = time(0);
      |        ^~
longesttrip.cpp:27:10: warning: variable 'it' set but not used [-Wunused-but-set-variable]
   27 |     auto it = ord.begin();
      |          ^~
# 결과 실행 시간 메모리 Grader output
1 Correct 30 ms 344 KB Output is correct
2 Incorrect 201 ms 692 KB Incorrect
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 344 KB Output is correct
2 Correct 1 ms 344 KB Output is correct
3 Correct 0 ms 344 KB Output is correct
4 Correct 0 ms 344 KB Output is correct
5 Correct 0 ms 344 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 2815 ms 344 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 2795 ms 344 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 2821 ms 596 KB Time limit exceeded
2 Halted 0 ms 0 KB -