답안 #394302

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
394302 2021-04-26T11:08:00 Z MarcoMeijer 악어의 지하 도시 (IOI11_crocodile) C++14
100 / 100
1082 ms 88480 KB
#include "crocodile.h"
#include <bits/stdc++.h>
using namespace std;

// macros
typedef long long ll;
typedef long double ld;
typedef pair<int, int> ii;
typedef pair<ll, ll> lll;
typedef tuple<int, int, int> iii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef vector<iii> viii;
typedef vector<ll> vll;
typedef vector<lll> vlll;
#define REP(a,b,c) for(int a=int(b); a<int(c); a++)
#define RE(a,c) REP(a,0,c)
#define RE1(a,c) REP(a,1,c+1)
#define REI(a,b,c) REP(a,b,c+1)
#define REV(a,b,c) for(int a=int(c-1); a>=int(b); a--)
#define FOR(a,b) for(auto& a : b)
#define all(a) a.begin(), a.end()
#define INF 1e18
#define EPS 1e-9
#define pb push_back
#define popb pop_back
#define fi first
#define se second
#define sz size()

int travel_plan(int N, int M, int R[][2], int L[], int K, int P[]) {
    // create graph
    vector<vi > adj;  adj .resize(N);
    vector<vii> adjD; adjD.resize(N);
    RE(i,M) RE(j,2) adj [R[i][j]].pb(R[i][!j]);
    RE(i,M) RE(j,2) adjD[R[i][j]].pb({R[i][!j], L[i]});

    // initial dijktra
    vll dist[2];
    RE(j,2) dist[j].assign(N, INF);
    priority_queue<lll,vlll,greater<lll>> pq;
    RE(i,K) {
        pq.push({0,P[i]});
        pq.push({0,P[i]});
    }

    // dijkstra
    while(!pq.empty()) {
        ll d = pq.top().fi;
        ll u = pq.top().se;
        pq.pop();
        if(dist[1][u] != INF) continue;
        if(dist[0][u] == INF) {
            dist[0][u] = d;
            continue;
        } else {
            dist[1][u] = d;
        }
        FOR(p,adjD[u]) {
            ll v = p.fi;
            if(dist[1][v] != INF) continue;
            pq.push({d + p.se, v});
        }
    }

    return dist[1][0];
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 208 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 304 KB Output is correct
4 Correct 2 ms 460 KB Output is correct
5 Correct 2 ms 460 KB Output is correct
6 Correct 1 ms 460 KB Output is correct
7 Correct 2 ms 440 KB Output is correct
8 Correct 1 ms 460 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 208 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 304 KB Output is correct
4 Correct 2 ms 460 KB Output is correct
5 Correct 2 ms 460 KB Output is correct
6 Correct 1 ms 460 KB Output is correct
7 Correct 2 ms 440 KB Output is correct
8 Correct 1 ms 460 KB Output is correct
9 Correct 3 ms 844 KB Output is correct
10 Correct 1 ms 332 KB Output is correct
11 Correct 2 ms 460 KB Output is correct
12 Correct 6 ms 1232 KB Output is correct
13 Correct 5 ms 1328 KB Output is correct
14 Correct 1 ms 332 KB Output is correct
15 Correct 2 ms 460 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 208 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 304 KB Output is correct
4 Correct 2 ms 460 KB Output is correct
5 Correct 2 ms 460 KB Output is correct
6 Correct 1 ms 460 KB Output is correct
7 Correct 2 ms 440 KB Output is correct
8 Correct 1 ms 460 KB Output is correct
9 Correct 3 ms 844 KB Output is correct
10 Correct 1 ms 332 KB Output is correct
11 Correct 2 ms 460 KB Output is correct
12 Correct 6 ms 1232 KB Output is correct
13 Correct 5 ms 1328 KB Output is correct
14 Correct 1 ms 332 KB Output is correct
15 Correct 2 ms 460 KB Output is correct
16 Correct 841 ms 80480 KB Output is correct
17 Correct 99 ms 19912 KB Output is correct
18 Correct 133 ms 22212 KB Output is correct
19 Correct 1082 ms 88480 KB Output is correct
20 Correct 561 ms 73532 KB Output is correct
21 Correct 51 ms 8260 KB Output is correct
22 Correct 486 ms 52428 KB Output is correct