답안 #727366

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
727366 2023-04-20T13:40:41 Z MisterReaper 악어의 지하 도시 (IOI11_crocodile) C++17
컴파일 오류
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> 

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

crocodile.cpp:11:14: fatal error: debug.h: No such file or directory
   11 |     #include "debug.h"
      |              ^~~~~~~~~
compilation terminated.