답안 #1037874

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1037874 2024-07-29T09:30:33 Z Zicrus 가장 긴 여행 (IOI23_longesttrip) C++17
15 / 100
1000 ms 1444 KB
#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;
    for (int i = 0; i < 100; i++) {
        vector<int> nw = mxRand();
        if (nw.size() > res.size()) res = nw;
    }
    return res;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 229 ms 1096 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 11 ms 344 KB Output is correct
2 Correct 23 ms 344 KB Output is correct
3 Correct 191 ms 456 KB Output is correct
4 Correct 502 ms 1076 KB Output is correct
5 Correct 990 ms 1168 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 10 ms 352 KB Output is correct
2 Correct 29 ms 344 KB Output is correct
3 Correct 172 ms 600 KB Output is correct
4 Correct 498 ms 592 KB Output is correct
5 Correct 951 ms 1080 KB Output is correct
6 Correct 9 ms 344 KB Output is correct
7 Correct 36 ms 344 KB Output is correct
8 Correct 180 ms 344 KB Output is correct
9 Correct 395 ms 800 KB Output is correct
10 Correct 983 ms 1368 KB Output is correct
11 Correct 935 ms 1272 KB Output is correct
12 Correct 982 ms 1188 KB Output is correct
13 Correct 976 ms 1264 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 10 ms 344 KB Output is correct
2 Correct 29 ms 344 KB Output is correct
3 Correct 194 ms 460 KB Output is correct
4 Correct 475 ms 824 KB Output is correct
5 Execution timed out 1008 ms 1252 KB Time limit exceeded
6 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 11 ms 344 KB Output is correct
2 Correct 27 ms 344 KB Output is correct
3 Partially correct 178 ms 344 KB Output is partially correct
4 Partially correct 460 ms 600 KB Output is partially correct
5 Execution timed out 1008 ms 1444 KB Time limit exceeded
6 Halted 0 ms 0 KB -