Submission #1079802

# Submission time Handle Problem Language Result Execution time Memory
1079802 2024-08-29T01:57:44 Z _rain_ Crocodile's Underground City (IOI11_crocodile) C++14
Compilation error
0 ms 0 KB
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define fixbug false

void SETIO(string name = ""){
    if (name=="") return ;
    freopen((name+".inp").c_str(),"r",stdin);
    freopen((name+".out").c_str(),"w",stdout);
    return;
}
//... READ INPUT
    const int maxn = 50000;
    const int maxm = 10000000;
    static int R[maxm+2][2];
    static int L[maxn+2];
    static int P[maxn+2];
    int n , m , k;

vector<pair<int,int>> g[maxn+2];
ll d[maxn+2][2];
bool ex[maxn+2];
#define ii pair<ll,int>
#define fi first
#define se second

int travel(int n , int m , int R[][2] , int L[] , int k , int P[]){
    for (int i = 0; i < m; ++i) {
        g[R[i][0]].push_back({R[i][1] , L[i]});
        g[R[i][1]].push_back({R[i][0] , L[i]});
        if (fixbug){
            cout << R[i][0] << ' ' << R[i][1] << ' ' << L[i] << '\n';
        }
    }
    priority_queue<ii,vector<ii>,greater<ii>> q;
    memset(d,0x3f,sizeof d);
    ll ans = d[0][0];
    for (int i = 0 ; i < k; ++i){
        d[P[i]][0] = d[P[i]][1] = 0;
        q.push({0 , P[i]});
    }
    while (q.size()){
        int u = q.top().second; ll cost = q.top().first;
        q.pop();
        if (cost != d[u][0]) continue;
        if (fixbug){
            cout << "(DEBUG)\n";
            cout << u << ' ' << cost << "\n";
        }

        for (auto & x : g[u]){
            int v = x.first , w = x.second;
            if (d[v][0] > cost + w){
                d[v][0] = cost + w;
                if (d[v][1] > d[v][0]) swap(d[v][1] , d[v][0]);
                q.push({d[v][0] , v});
            }
        }
    }
    if (fixbug){
        cout << ans << '\n';
        for (int i = 0; i < n; ++i) cout << d[i][0] << '\n';
    }
    return d[0][0];
}

Compilation message

crocodile.cpp: In function 'void SETIO(std::string)':
crocodile.cpp:8:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
    8 |     freopen((name+".inp").c_str(),"r",stdin);
      |     ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
crocodile.cpp:9:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
    9 |     freopen((name+".out").c_str(),"w",stdout);
      |     ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
crocodile.cpp: At global scope:
crocodile.cpp:17:16: warning: 'P' defined but not used [-Wunused-variable]
   17 |     static int P[maxn+2];
      |                ^
crocodile.cpp:16:16: warning: 'L' defined but not used [-Wunused-variable]
   16 |     static int L[maxn+2];
      |                ^
crocodile.cpp:15:16: warning: 'R' defined but not used [-Wunused-variable]
   15 |     static int R[maxm+2][2];
      |                ^
/usr/bin/ld: /tmp/ccaZQUjG.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