Submission #1041875

# Submission time Handle Problem Language Result Execution time Memory
1041875 2024-08-02T08:58:37 Z stdfloat Swapping Cities (APIO20_swap) C++17
Compilation error
0 ms 0 KB
#include <bits/stdc++.h>
#include "swap.h"
#include "grader.cpp"
using namespace std;

using ll = long long;

#define ff  first
#define ss  second
#define pii pair<int, int>

int n;

vector<vector<pii>> E;

void init(int N, int M, vector<int> U, vector<int> V, vector<int> W) {
    n = N;
    E.assign(n, {});
    for (int i = 0; i < M; i++) {
        E[U[i]].push_back({V[i], W[i]});
        E[V[i]].push_back({U[i], W[i]});
    }
}

int getMinimumFuelCapacity(int X, int Y) {
    int l = 0, r = (int)1e9 + 1;
    while (l < r) {
        int md = (l + r) >> 1;

        bool tr = false;
        queue<pii> q;
        vector<bool> visX(n);
        vector<int> p(n, -1);
        q.push({X, -1}); visX[X] = true;
        while (!q.empty()) {
            auto [x, pr] = q.front(); q.pop();

            for (auto [i, w] : E[x]) {
                if (i == pr || w > md) continue;
                if (visX[i]) {
                    if (i == X) {
                        tr = true;
                        break;
                    }
                }
                else {
                    p[i] = x;
                    q.push({i, x});
                    visX[i] = true;
                }
            }
        }

        if (!visX[Y]) {
            l = md + 1;
            continue;
        }

        vector<bool> visY(n);
        queue<pii> q1;
        q1.push({Y, -1}); visY[Y] = true;
        while (!q1.empty() && !tr) {
            auto [x, p] = q1.front(); q1.pop();
        
            for (auto [i, w] : E[x]) {
                if (w > md || i == p) continue;

                if (visY[i]) {
                    if (i == Y || visX[i]) {
                        tr = true;
                        break;
                    }
                }
                else {
                    visY[i] = true;
                    q1.push({i, x});
                }
            }
        }

        int x = Y;
        while (x != X && !tr) {
            x = p[x];

            int cnt = 0;
            for (auto [i, w] : E[x]) {
                cnt += (w <= md);
            }

            tr = (cnt > 2);
        }

        if (!tr) l = md + 1;
        else r = md;
    }

    return (l == (int)1e9 + 1 ? -1 : l);
}

Compilation message

/usr/bin/ld: /tmp/ccJsB3LT.o: in function `main':
grader.cpp:(.text.startup+0x0): multiple definition of `main'; /tmp/ccBLYLzU.o:swap.cpp:(.text.startup+0x0): first defined here
collect2: error: ld returned 1 exit status