제출 #1037896

#제출 시각아이디문제언어결과실행 시간메모리
1037896Zicrus가장 긴 여행 (IOI23_longesttrip)C++17
40 / 100
911 ms1584 KiB
#include <bits/stdc++.h>
#include "longesttrip.h"
using namespace std;

typedef long long ll;

vector<vector<ll>> adj;
vector<bool> vst;
mt19937 mt;

vector<int> mxRand() {
    ll n = adj.size();
    ll start = mt() % n;
    ll cur = start;
    vector<int> res = {(int)start};
loop:
    vst[cur] = true;
    shuffle(adj[cur].begin(), adj[cur].end(), mt);
    for (auto &e : adj[cur]) {
        if (!vst[e]) {
            cur = e;
            res.push_back(e);
            goto loop;
        }
    }
    for (auto &e : res) vst[e] = false;
    return res;
}

vector<int> longest_trip(int n, int d) {
    mt = mt19937(time(0));
    adj = vector<vector<ll>>(n);
    vst = vector<bool>(n);
    for (int i = 0; i < n; i++) {
        for (int j = i+1; j < n; j++) {
            if (are_connected({i}, {j})) {
                adj[i].push_back(j);
                adj[j].push_back(i);
            }
        }
    }

    vector<int> res;
    ll comp = n <= 100 ? 150 : 50;
    if (n <= 50) comp = 300;
    for (int i = 0; i < 50; i++) {
        vector<int> nw = mxRand();
        if (nw.size() > res.size()) res = nw;
    }
    return res;
}

컴파일 시 표준 에러 (stderr) 메시지

longesttrip.cpp: In function 'std::vector<int> longest_trip(int, int)':
longesttrip.cpp:44:8: warning: variable 'comp' set but not used [-Wunused-but-set-variable]
   44 |     ll comp = n <= 100 ? 150 : 50;
      |        ^~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...