Submission #1214628

#TimeUsernameProblemLanguageResultExecution timeMemory
1214628trimkus축구 경기장 (IOI23_soccer)C++20
Compilation error
0 ms0 KiB
#include "longesttrip.h"
#include <bits/stdc++.h>

using namespace std;
int N;
const int MAXN = 256;
vector<int> adj[MAXN];


void connect(vector<int>& path1, vector<int>& path2) {
    reverse(begin(path2), end(path2));
    for (int j = 0; j < (int)path2.size(); ++j) {
        path1.push_back(path2[j]);
    }
    path2.clear();
}

std::vector<int> longest_trip(int _N, int D)
{
    N = _N;
    vector<int> idx(N);
    iota(begin(idx), end(idx), 0);
    mt19937 rng(0);
    shuffle(begin(idx), end(idx), rng);
    bool not_connected = false;
    vector<int> path1{idx[0]}, path2{idx[1]};
    for (int j = 2; j < N; ++j) {
        int i = idx[j];
        if (are_connected({path1.back()}, {i})) {
            path1.push_back(i);
            not_connected = false;
        } else {
            if (not_connected) {
                path2.push_back(i);
            } else {
                if (are_connected({path2.back()}, {i})) {
                    not_connected = true;
                    path2.push_back(i);
                } else {
                    connect(path1, path2);
                    path2 = {i};
                    not_connected = false;
                }
            }
        }
    }
    if (path1.size() < path2.size()) swap(path1, path2);
    if (path2.size() == 0) return path1;
    if (!are_connected(path1, path2)) return path1;
    // if (are_connected({path1.back()}, {path2.back()})) {
    //     connect(path1, path2);
    //     return path1;
    // }
    // reverse(begin(path1), end(path1));
    // if (are_connected({path1.back()}, {path2.back()})) {
    //     connect(path1, path2);
    //     return path1;
    // }
    // reverse(begin(path1), end(path1));
    // reverse(begin(path2), end(path2));
    // if (are_connected({path1.back()}, {path2.back()})) {
    //     connect(path1, path2);
    //     return path1;
    // }
    // reverse(begin(path1), end(path1));
    // if (are_connected({path1.back()}, {path2.back()})) {
    //     connect(path1, path2);
    //     return path1;
    // }
    // reverse(begin(path1), end(path1));
    // reverse(begin(path2), end(path2));
    // cerr << "Path1 = ";
    // for (auto& u : path1) {
    //     cerr << u << " ";
    // }
    // cerr << "\nPath2 = ";
    // for (auto& u : path2) {
    //     cerr << u << " ";
    // }
    // cerr << "\n";
    vector<int> super_path;
    int l1 = 0, r1 = (int)path1.size();
    int l2 = 0, r2 = (int)path2.size();
    while (r1 - l1 > 1) {
        int m1 = (l1 + r1) / 2;
        if (are_connected(vector<int>(begin(path1) + l1, begin(path1) + m1),
            vector<int>(begin(path2) + l2, begin(path2) + r2))) {
            r1 = m1;
        } else {
            l1 = m1;
        }
    }
    while (r2 - l2 > 1) {
        int m2 = (l2 + r2) / 2;
        if (are_connected(vector<int>(begin(path1) + l1, begin(path1) + r1),
            vector<int>(begin(path2) + l2, begin(path2) + m2))) {
            r2 = m2;
        } else {
            l2 = m2;
        }
    }
    assert(l1 < (int)path1.size());
    assert(l2 < (int)path2.size());
    vector<int> res;
    for (int i = l1; i < (int)path1.size(); ++i) {
        res.push_back(path1[i]);
    }
    for (int i = 0; i < l1; ++i) {
        res.push_back(path1[i]);
    }
    reverse(begin(res), end(res));
    for (int i = l2; i < (int)path2.size(); ++i) {
        res.push_back(path2[i]);
    }
    for (int i = 0; i < l2; ++i) {
        res.push_back(path2[i]);
    }
    return res;
}

Compilation message (stderr)

soccer.cpp:1:10: fatal error: longesttrip.h: No such file or directory
    1 | #include "longesttrip.h"
      |          ^~~~~~~~~~~~~~~
compilation terminated.