Submission #697290

# Submission time Handle Problem Language Result Execution time Memory
697290 2023-02-09T06:28:12 Z vjudge1 Crocodile's Underground City (IOI11_crocodile) C++11
Compilation error
0 ms 0 KB
#include<iostream>
#include<vector>
#include<queue>
using namespace std;
const long long maxn = 100005;
const long long maxv = (long long) 1e18;
long long n,m,k,val[maxn][2];
bool beenTo[maxn];
vector<pair<long long,long long> > conn[maxn];
int main () {
    scanf("%lld%lld%lld",&n,&m,&k);
    for(long long i = 0; i < m; i++) {
        long long a,b,c;
        scanf("%lld%lld%lld",&a,&b,&c);
        conn[a].push_back(make_pair(c,b));
        conn[b].push_back(make_pair(c,a));
    }
    priority_queue<pair<long long,long long>,vector<pair<long long,long long> >,greater<pair<long long,long long> > > dijkstra;
    for(long long i = 0; i < n; i++) {
        val[i][0] = maxv;
        val[i][1] = maxv;
    }
    for(long long i = 0; i < k; i++) {
        long long a;
        scanf("%lld",&a);
        val[a][0] = 0;
        val[a][1] = 0;
        dijkstra.push(make_pair(0,a));
    }
    while(dijkstra.size() > 0) {
        pair<long long,long long> curr = dijkstra.top();
        dijkstra.pop();
        if(beenTo[curr.second] == true) continue;
        beenTo[curr.second] = true;
        for(long long i = 0; i < conn[curr.second].size(); i++) {
            pair<long long,long long> targ = conn[curr.second][i];
            if(val[targ.second][0] > val[curr.second][1]+targ.first) {
                val[targ.second][1] = val[targ.second][0];
                val[targ.second][0] = val[curr.second][1]+targ.first;
                dijkstra.push(make_pair(val[targ.second][1],targ.second));
            }
            else if(val[targ.second][1] > val[curr.second][1]+targ.first) {
                val[targ.second][1] = val[curr.second][1]+targ.first;
                dijkstra.push(make_pair(val[targ.second][1],targ.second));
            }
        }
    }
    printf("%lld\n",val[0][1]);
    return 0;
}

Compilation message

crocodile.cpp: In function 'int main()':
crocodile.cpp:35:32: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<std::pair<long long int, long long int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   35 |         for(long long i = 0; i < conn[curr.second].size(); i++) {
      |                              ~~^~~~~~~~~~~~~~~~~~~~~~~~~~
crocodile.cpp:11:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   11 |     scanf("%lld%lld%lld",&n,&m,&k);
      |     ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
crocodile.cpp:14:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   14 |         scanf("%lld%lld%lld",&a,&b,&c);
      |         ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
crocodile.cpp:25:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   25 |         scanf("%lld",&a);
      |         ~~~~~^~~~~~~~~~~
/usr/bin/ld: /tmp/ccTab92W.o: in function `main':
grader.cpp:(.text.startup+0x0): multiple definition of `main'; /tmp/ccz0flSX.o:crocodile.cpp:(.text.startup+0x0): first defined here
/usr/bin/ld: /tmp/ccTab92W.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