Submission #939603

# Submission time Handle Problem Language Result Execution time Memory
939603 2024-03-06T14:58:39 Z May27_th Crocodile's Underground City (IOI11_crocodile) C++17
Compilation error
0 ms 0 KB
#include<bits/stdc++.h>
#define taskname "A"
using namespace std;

void World_Final();
void Solve();

int main(){
    ios_base::sync_with_stdio(false); cin.tie(nullptr);
    if (fopen(taskname".in", "r")) {
        freopen(taskname".in", "r", stdin);
        freopen(taskname".out", "w", stdout);
    }
    World_Final();
}

void World_Final(){
    int Tests = 1;
    //cin >> Tests;
    for (int i = 1; i <= Tests; i ++) {
        //cout << i << "\n";
        Solve();
    }
}

const int MOD = 1e9 + 7;
const int MAXN = 2e5 + 10;
const int INF = 1e9;

int N, M, K, R[MAXN][2], par[MAXN], st[MAXN]; int64_t f[MAXN]; vector<pair<int, int64_t>> G[MAXN];
void Solve(){
    cin >> N >> M >> K;
    for (int i = 1; i <= M; i ++) {
        cin >> R[i][0] >> R[i][1];
    }
    for (int i = 1; i <= M; i ++) {
        int x; cin >> x;
        G[R[i][0]].push_back(make_pair(R[i][1], x));
        G[R[i][1]].push_back(make_pair(R[i][0], x));
    }
    priority_queue<pair<int64_t, int>> pq;
    memset(f, 0x3f3f, sizeof(f));
    for (int i = 0; i < K; i ++) {
        cin >> st[i]; f[st[i]] = 0;
        pq.push(make_pair(0, st[i]));
    }
    while (!pq.empty()) {
        int64_t d; int u; tie(d, u) = pq.top(); pq.pop();
        if (-d != f[u]) continue;
        for (auto [v, w] : G[u]) {
            if (f[v] > f[u] + w) {
                f[v] = f[u] + w;
                par[v] = u;
                pq.push(make_pair(-f[v], v));
            }
        }
    }
    memset(f, 0x3f3f, sizeof(f)); f[0] = 0; pq.push(make_pair(f[0], 0));
    while (!pq.empty()) {
        int64_t d; int u; tie(d, u) = pq.top(); pq.pop();
        if (-d != f[u]) continue;
        for (auto [v, w] : G[u]) {
            if (par[u] != v && f[v] > f[u] + w) {
                f[v] = f[u] + w;
                pq.push(make_pair(-f[v], v));
            }
        }
    }
    int64_t ans = 1e18;
    for (int i = 0; i < K; i ++) {
        ans = min(ans, f[st[i]]);
    }
    cout << ans;

}

Compilation message

crocodile.cpp: In function 'int main()':
crocodile.cpp:11:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   11 |         freopen(taskname".in", "r", stdin);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~
crocodile.cpp:12:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   12 |         freopen(taskname".out", "w", stdout);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/bin/ld: /tmp/cc8Db271.o: in function `main':
grader.cpp:(.text.startup+0x0): multiple definition of `main'; /tmp/ccqIBwl3.o:crocodile.cpp:(.text.startup+0x0): first defined here
/usr/bin/ld: /tmp/cc8Db271.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