Submission #370458

# Submission time Handle Problem Language Result Execution time Memory
370458 2021-02-24T03:39:33 Z gozonite Crocodile's Underground City (IOI11_crocodile) C++14
Compilation error
0 ms 0 KB
#include <bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef vector<int> vi;
typedef vector<pair<int, int>> vii;
typedef pair<int, int> pi;
#define MOD 1000000007LL

vector<pair<int, int>> adj[100000];
ll dis[100000];
pair<ll, ll> mdis[100000];

int travel_plan(int N, int M, int R[][2], int *L, int K, int *P) {
    //cout << "Debugging: " << N << " " << M << " " << K << endl;
    //for (int i = 0; i < M; i++) cout << R[i][0] << " " << R[i][1] << endl;
    //for (int i = 0; i < M; i++) cout << L[i] << " "; cout << endl;
    //for (int i = 0; i < K; i++) cout << P[i] << " "; cout << endl;
    
    for (int i = 0; i < N; i++) { adj[i].clear(); dis[i] = 1e18; mdis[i] = {1e18, 1e18}; }
    for (int i = 0; i < M; i++) {
        int a = R[i][0], b = R[i][1], w = L[i];
        adj[a].push_back({b, w});
        adj[b].push_back({a, w});
    }
    
    using T = pair<ll, ll>; priority_queue<T, vector<T>, greater<T>> q;
    for (int i = 0; i < K; i++) { q.push({0, P[i]}); dis[P[i]] = 0; }
    
    while (!q.empty()) {
        ll v = q.top().second, ow = q.top().first; q.pop();
        if (dis[v] < ow) continue;
        for (auto pp : adj[v]) {
            ll u = pp.first, w = pp.second;
            if (dis[v]+w <= mdis[u].first) {
                mdis[u].second = mdis[u].first;
                mdis[u].first = dis[v]+w;
            } else if (dis[v]+w <= mdis[u].second) {
                mdis[u].second = dis[v]+w;
            }
            
            if (mdis[u].second < dis[u]) {
                dis[u] = mdis[u].second;
                q.push({dis[u], u});
            }
        }
        //cout << "processed: " << v << " " << dis[v] << endl;
    }
    
    //cout << "Debugging dis, mdis" << endl;
    //for (int i = 0; i < N; i++) cout << dis[i] << " "; cout << endl;
    //for (int i = 0; i < N; i++) cout << mdis[i].first << " "; cout << endl;
    //for (int i = 0; i < N; i++) cout << mdis[i].second << " "; cout << endl;
    
    return dis[0];
}

int main() {
    //freopen("feast.in", "r", stdin);
    //freopen("feast.out", "w", stdout);
    //ios_base::sync_with_stdio(false);
    //cin.tie(0);
    
    /*
    // tc1
    int N = 5, M = 4, K = 3;
    int R[4][2] = { {0, 1},
                   {0, 2},
                   {3, 2},
                   {2, 4} };
    int L[] = {2, 3, 1, 4};
    int P[] = {1, 3, 4};
    cout << travel_plan(N, M, R, L, K, P) << endl;
    
    // tc2
    N = 5, M = 7, K = 2;
    int R2[][2] = { {0, 2},
                    {0, 3},
                    {3, 2},
                    {2, 1},
                    {0, 1},
                    {0, 4},
                    {3, 4} };
    int L2[] = {4, 3, 2, 10, 100, 7, 9};
    int P2[] = {1, 3};
    cout << travel_plan(N, M, R2, L2, K, P2) << endl;*/
}

Compilation message

/tmp/ccYx98M4.o: In function `main':
grader.cpp:(.text.startup+0x0): multiple definition of `main'
/tmp/ccXlm56B.o:crocodile.cpp:(.text.startup+0x0): first defined here
collect2: error: ld returned 1 exit status