답안 #697291

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
697291 2023-02-09T06:33:35 Z vjudge1 악어의 지하 도시 (IOI11_crocodile) C++11
컴파일 오류
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];
priority_queue<pair<long long,long long>,vector<pair<long long,long long> >,greater<pair<long long,long long> > > dijkstra;
int travel_plan(int N, int M, int R[][2], int W[], int K, int E[]) {
    n = N;
    m = M;
    k = K;
    for(int i = 0; i < m; i++) {
        int a = R[i][0];
        int b = R[i][1];
        int c = W[i];
        conn[a].push_back(make_pair(c,b));
        conn[b].push_back(make_pair(c,a));
    }
    for(int i = 0; i < k; i++) {
        int a = E[i];
        val[a][0] = 0;
        val[a][1] = 0;
        dijkstra.push(make_pair(0,a));
    }
    for(long long i = 0; i < n; i++) {
        val[i][0] = maxv;
        val[i][1] = maxv;
    }
    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));
            }
        }
    }
    return val[0][1];
}
int main () {}

Compilation message

crocodile.cpp: In function 'int travel_plan(int, int, int (*)[2], int*, int, int*)':
crocodile.cpp:37: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]
   37 |         for(long long i = 0; i < conn[curr.second].size(); i++) {
      |                              ~~^~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/bin/ld: /tmp/ccePZOlc.o: in function `main':
grader.cpp:(.text.startup+0x0): multiple definition of `main'; /tmp/ccYdlSig.o:crocodile.cpp:(.text.startup+0x0): first defined here
collect2: error: ld returned 1 exit status