Submission #232197

# Submission time Handle Problem Language Result Execution time Memory
232197 2020-05-16T10:55:24 Z semiauto Crocodile's Underground City (IOI11_crocodile) C++11
Compilation error
0 ms 0 KB
#include <bits/stdc++.h>
using namespace std;
vector <pair<int,int> > v[1000000];
priority_queue <pair<int,int> > q;
pair <int,int> ans[1000000];
int main() {
    int n, m, k;
    cin >> n >> m >> k;
    for (int i = 0; i < n; i++) {
        ans[i] = {1000000000, 1000000000};
    }
    for (int i = 0; i < m; i++) {
        int a, b, c;
        scanf("%d %d %d", &a, &b, &c);
        v[a].push_back({b, c});
        v[b].push_back({a, c});
    }
    for (int i = 0; i < k; i++) {
        int a;
        cin >> a;
        q.push({0, a});
        ans[a] = {0,0};
    }
    while (q.size()) {
        int p = q.top().second;
        int pp = q.top().first;
        q.pop();
        if (ans[p].second + pp != 0)
            continue;
        for (int i = 0; i < v[p].size(); i++) {
            int a = v[p][i].first;
            int b = v[p][i].second;
            if (ans[a].second <= ans[p].second + b)
                continue;
            if (ans[a].first <= ans[p].second + b) {
                ans[a].second = ans[p].second + b;
            } else {
                ans[a].second = ans[a].first;
                ans[a].first = ans[p].second + b;
            }
            q.push({-ans[a].second, a});
        }
    }
    cout << ans[0].second << endl;
}

Compilation message

crocodile.cpp: In function 'int main()':
crocodile.cpp:30:27: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
         for (int i = 0; i < v[p].size(); i++) {
                         ~~^~~~~~~~~~~~~
crocodile.cpp:14:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%d %d %d", &a, &b, &c);
         ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
/tmp/ccEpMF8O.o: In function `main':
grader.cpp:(.text.startup+0x0): multiple definition of `main'
/tmp/cc83aZ98.o:crocodile.cpp:(.text.startup+0x0): first defined here
/tmp/ccEpMF8O.o: In function `main':
grader.cpp:(.text.startup+0x2d): undefined reference to `travel_plan(int, int, int (*) [2], int*, int, int*)'
collect2: error: ld returned 1 exit status