답안 #667076

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
667076 2022-11-30T10:47:33 Z 1bin 악어의 지하 도시 (IOI11_crocodile) C++17
100 / 100
485 ms 45200 KB
#include <bits/stdc++.h>
#include "crocodile.h"
#include <cassert>
 
using namespace std;
 
#define all(v) v.begin(), v.end()
typedef long long ll;
const int NMAX = 1e5 + 5;
int n, m, k, dist[NMAX][2], R[NMAX * 10][2], L[NMAX * 10], P[NMAX], v[NMAX], a, b;
vector<pair<int, int>> adj[NMAX];
 
int travel_plan(int N_, int M_, int R_[][2], int L_[], int K_, int P_[]){
    n = N_; m = M_; k = K_;
    for(int i = 0; i < m; i++){
        a = R_[i][0]; b = R_[i][1];
        adj[a].emplace_back(b, L_[i]);
        adj[b].emplace_back(a, L_[i]);
    }
    
    memset(dist, 0x3f, sizeof(dist));
    priority_queue<pair<int, int>> pq;
    for(int i = 0; i < k; i++) {
        dist[P_[i]][0] = dist[P_[i]][1] = 0;
        pq.emplace(0, P_[i]);
        v[P_[i]] = 1;
    }
    
    while(pq.size()){
        auto[d, x] = pq.top(); pq.pop();
        d = -d;
        if(++v[x] != 2) continue;
        
        for(auto&[nx, p] : adj[x]){
            ll nxd = d + p;
            if(nxd < dist[nx][1]){
                pq.emplace(-nxd, nx);
                dist[nx][1] = nxd;
                if(dist[nx][0] > dist[nx][1]) swap(dist[nx][0], dist[nx][1]);
            }
        }
    }
    assert(dist[0][1] <= 1e9);
    return dist[0][1];
}
 
/*
int main(void){
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    
    cin >> n >> m >> k;
    for(int i = 0; i < m; i++) cin >> R[i][0] >> R[i][1] >> L[i];
    for(int i = 0; i < k; i++) cin >> P[i];
    int ans;
    cin >> ans;
    cout << travel_plan(n, m, R, L, k, P);
    cout << ' ' << ans << '\n';
    return 0;
}
*/
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 3432 KB Output is correct
2 Correct 2 ms 3412 KB Output is correct
3 Correct 2 ms 3412 KB Output is correct
4 Correct 2 ms 3412 KB Output is correct
5 Correct 2 ms 3412 KB Output is correct
6 Correct 2 ms 3412 KB Output is correct
7 Correct 2 ms 3412 KB Output is correct
8 Correct 2 ms 3412 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 3432 KB Output is correct
2 Correct 2 ms 3412 KB Output is correct
3 Correct 2 ms 3412 KB Output is correct
4 Correct 2 ms 3412 KB Output is correct
5 Correct 2 ms 3412 KB Output is correct
6 Correct 2 ms 3412 KB Output is correct
7 Correct 2 ms 3412 KB Output is correct
8 Correct 2 ms 3412 KB Output is correct
9 Correct 3 ms 3668 KB Output is correct
10 Correct 2 ms 3412 KB Output is correct
11 Correct 2 ms 3540 KB Output is correct
12 Correct 5 ms 3796 KB Output is correct
13 Correct 4 ms 3796 KB Output is correct
14 Correct 2 ms 3412 KB Output is correct
15 Correct 2 ms 3584 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 3432 KB Output is correct
2 Correct 2 ms 3412 KB Output is correct
3 Correct 2 ms 3412 KB Output is correct
4 Correct 2 ms 3412 KB Output is correct
5 Correct 2 ms 3412 KB Output is correct
6 Correct 2 ms 3412 KB Output is correct
7 Correct 2 ms 3412 KB Output is correct
8 Correct 2 ms 3412 KB Output is correct
9 Correct 3 ms 3668 KB Output is correct
10 Correct 2 ms 3412 KB Output is correct
11 Correct 2 ms 3540 KB Output is correct
12 Correct 5 ms 3796 KB Output is correct
13 Correct 4 ms 3796 KB Output is correct
14 Correct 2 ms 3412 KB Output is correct
15 Correct 2 ms 3584 KB Output is correct
16 Correct 382 ms 42788 KB Output is correct
17 Correct 63 ms 10872 KB Output is correct
18 Correct 98 ms 12196 KB Output is correct
19 Correct 485 ms 45200 KB Output is correct
20 Correct 234 ms 37328 KB Output is correct
21 Correct 37 ms 6860 KB Output is correct
22 Correct 277 ms 32536 KB Output is correct