제출 #725679

#제출 시각아이디문제언어결과실행 시간메모리
725679Bogdan1110악어의 지하 도시 (IOI11_crocodile)C++14
100 / 100
459 ms48788 KiB
#include <bits/stdc++.h>
#define FAST {ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);}
#define FILES {freopen("input.txt", "r", stdin);freopen("output.txt", "w", stdout);}
#define ll long long
#define ull unsigned long long
#define pqueue priority_queue
#define pb push_back
#define fi first
#define se second
#define ld long double
#define pii pair<int,int>
#define pll pair<long long,long long>
#define all(a) (a).begin(), (a).end()
#define mp make_pair 
using namespace std;
// order_of_key -> # less than k
// find_by_order -> k-th element
// pq max element
 
void files() {
    #ifndef ONLINE_JUDGE
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif
}

const double eps = 0.00000001;
const int NMAX = 100010;
const ll inf = LLONG_MAX/3;
const ll modi = 998244353;

vector<pii>al[NMAX];
int d[NMAX][2];
int visited[NMAX];
int travel_plan(int n, int m, int r[][2], int l[], int k, int p[]) {

    for (int i = 0 ; i < m ; i++ ) {
        al[r[i][0]].pb({r[i][1], l[i]});
        al[r[i][1]].pb({r[i][0], l[i]});
    }

    priority_queue<pii>q;
    for (int i = 0 ; i < k ; i++ ) {
        q.push({0,p[i]});
    }

    for (int i = 0 ; i < NMAX ; i++ ) {
        d[i][0] = d[i][1] = INT_MAX;
    }

    while(!q.empty()) {
        int nd = q.top().se;
        int dist = -q.top().fi;
        q.pop();
        if ( visited[nd] ) continue;
        visited[nd] = true;
        if ( nd == 0 ) return dist;
        for (auto u : al[nd]) {
            int sl = u.fi;
            int kol = u.se;
            if ( dist + kol < d[sl][1] ) {
                d[sl][1] = dist + kol;
                if ( d[sl][1] < d[sl][0] ) swap(d[sl][0], d[sl][1]);
                if ( d[sl][1] < INT_MAX ) q.push({-d[sl][1], sl});
            }
        }
    }
    return 0;
}

컴파일 시 표준 에러 (stderr) 메시지

crocodile.cpp: In function 'void files()':
crocodile.cpp:22:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   22 |         freopen("input.txt", "r", stdin);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
crocodile.cpp:23:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   23 |         freopen("output.txt", "w", stdout);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...