답안 #1084292

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1084292 2024-09-05T18:40:57 Z vjudge1 악어의 지하 도시 (IOI11_crocodile) C++14
컴파일 오류
0 ms 0 KB
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef pair<int, int> ii;
typedef pair<ll, int> lli;
typedef priority_queue< lli, vector<lli>, greater<lli> > PQ;

const int MAXN = 100010;

int n, m, k;
vector<int> adj[MAXN];
vector<int> len[MAXN];
int vis[MAXN];
ll ans;

int main() {
    scanf("%d%d%d", &n, &m, &k);
    for (int i = 0; i < m; i++) {
        int u, v, l;
        scanf("%d%d%d", &u, &v, &l);
        adj[u].push_back(v);
        adj[v].push_back(u);
        len[u].push_back(l);
        len[v].push_back(l);
    }
    PQ pq;
    for (int i = 0; i < k; i++) {
        int x;
        scanf("%d", &x);
        pq.push({ 0, x });
        vis[x] = 1;
    }
    while (!pq.empty()) {
        int u = pq.top().second;
        ll l = pq.top().first;
        pq.pop();
        if (!vis[u]) {
            vis[u] = 1;
            continue;
        }
        if (vis[u] == 2) {
            continue;
        }
        if (u == 0) {
            ans = l;
            break;
        }
        vis[u] = 2;
        for (int i = 0; i < adj[u].size(); i++) {
            int v = adj[u][i];
            ll nl = l + len[u][i];
            if (vis[v] == 2) continue;
            pq.push({ nl, v });
        }
     }
     printf("%lld\n", ans);
}

Compilation message

crocodile.cpp: In function 'int main()':
crocodile.cpp:51:27: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   51 |         for (int i = 0; i < adj[u].size(); i++) {
      |                         ~~^~~~~~~~~~~~~~~
crocodile.cpp:19:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   19 |     scanf("%d%d%d", &n, &m, &k);
      |     ~~~~~^~~~~~~~~~~~~~~~~~~~~~
crocodile.cpp:22:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   22 |         scanf("%d%d%d", &u, &v, &l);
      |         ~~~~~^~~~~~~~~~~~~~~~~~~~~~
crocodile.cpp:31:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   31 |         scanf("%d", &x);
      |         ~~~~~^~~~~~~~~~
/usr/bin/ld: /tmp/cchTcBar.o: in function `main':
grader.cpp:(.text.startup+0x0): multiple definition of `main'; /tmp/ccNOdWpq.o:crocodile.cpp:(.text.startup+0x0): first defined here
/usr/bin/ld: /tmp/cchTcBar.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