Submission #727369

# Submission time Handle Problem Language Result Execution time Memory
727369 2023-04-20T13:41:11 Z MisterReaper Crocodile's Underground City (IOI11_crocodile) C++17
Compilation error
0 ms 0 KB
// author: MisterReaper (Ahmet Alp Orakci)
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define Data pair <Best, int> 
#define ONLINE_JUDGE

const int MAXN = 1e5 + 5;
const int INF = 1e18;

#ifndef ONLINE_JUDGE
    #include "debug.h"
    #define OPEN freopen(".in", "r", stdin); freopen(".out", "w", stdout);
    #define TIME cerr << fixed << setprecision(2) << 1000.0 * clock() / CLOCKS_PER_SEC << " milliseconds ";
#else
    #define debug(...) void(23)
    #define OPEN void(0000)
    #define TIME void(232323233)
#endif

struct Best
{
    int val1, val2;
    Best(int a = INF, int b = INF) : val1(a), val2(b) {}

    void add(int x)
    {
        if(x <= val1)
        {
            val2 = val1;
            val1 = x;
        }

        else if(x <= val2)
        {
            val2 = x;
        }
    }
    bool ok() {return val1 != INF && val2 != INF;}
};

bool operator> (Best a, Best b)
{
    return (a.val2 != b.val2) ? a.val2 > b.val2 : a.val1 > b.val1;
}
bool operator< (Best a, Best b)
{
    return (a.val2 != b.val2) ? a.val2 < b.val2 : a.val1 < b.val1;
}
bool operator== (Best a, Best b)
{
    return a.val1 == b.val1 && a.val2 == b.val2;
}
bool operator!= (Best a, Best b)
{
    return !(a == b);
}

vector <pair <int, int>> graph[MAXN];
Best dists[MAXN];

void solve()
{
    int n, m, k; cin >> n >> m >> k;
    for(int i = 1; i <= m; i++)
    {
        int u, v, c; cin >> u >> v >> c;

        graph[u].emplace_back(v, c);
        graph[v].emplace_back(u, c);
    }

    priority_queue <Data, vector <Data>, greater <Data>> pq;

    for(int i = 1; i <= k; i++)
    {
        int x; cin >> x;
        dists[x] = {0, 0};
        pq.emplace(dists[x], x);
    }

    while(!pq.empty())
    {
        Best val = pq.top().first; int node = pq.top().second;
        pq.pop();
        
        if(dists[node] != val) continue;
        debug(node);

        for(auto [child, c] : graph[node])
        {
            int cost = val.val2 + c;
            Best childval = dists[child]; childval.add(cost);
            debug(childval.val1, childval.val2);

            if(childval < dists[child])
            {
                dists[child] = childval;
                if(dists[child].ok())
                {
                    pq.emplace(childval, child);
                }
            }
        }
    }
    for(int i = 0; i < n; i++)
    {
        cerr << dists[i].val1 << " " << dists[i].val2 << "\n";
    }

    cout << dists[0].val2;
    
    return;
}

int32_t main()
{
    OPEN;

    ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);

    int t = 1; //cin >> t;
    while(t--)
    {
        solve();
    }

    TIME;

    return 0;
}

Compilation message

/usr/bin/ld: /tmp/ccGcXRcb.o: in function `main':
grader.cpp:(.text.startup+0x0): multiple definition of `main'; /tmp/ccWnZXEc.o:crocodile.cpp:(.text.startup+0x0): first defined here
/usr/bin/ld: /tmp/ccGcXRcb.o: in function `main':
grader.cpp:(.text.startup+0x36): undefined reference to `travel_plan(int, int, int (*) [2], int*, int, int*)'
collect2: error: ld returned 1 exit status