답안 #753576

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
753576 2023-06-05T14:14:02 Z nonono 악어의 지하 도시 (IOI11_crocodile) C++14
100 / 100
468 ms 66880 KB
#include "crocodile.h"
#include "bits/stdc++.h"
using namespace std;

int travel_plan(int N, int M, int R[][2], int L[], int K, int P[]){
    vector<pair<int, int>> adj[N];
    
    for(int i = 0; i < M; i ++){
        adj[R[i][0]].push_back({R[i][1], L[i]});
        adj[R[i][1]].push_back({R[i][0], L[i]});
    }
    
    int T[N];
    for(int i = 0; i < N; i ++) T[i] = 0;
    
    priority_queue<pair<int, int>, vector<pair<int, int>>, greater<pair<int, int>>> pq;
    
    for(int i = 0; i < K; i ++){
        pq.push({0, P[i]});
        T[P[i]] = 1;
    }
    
    while(!pq.empty()){
        int u = pq.top().second;
        int du = pq.top().first;
        pq.pop();
        
        T[u] ++ ;
        if(T[u] == 2){
            if(!u) return du;
            
            for(auto [v, w] : adj[u]){
                if(T[v] >= 2) continue ;
                pq.push({du + w, v});
            }
        }
    }
    
    return -1;
}


Compilation message

crocodile.cpp: In function 'int travel_plan(int, int, int (*)[2], int*, int, int*)':
crocodile.cpp:32:22: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17'
   32 |             for(auto [v, w] : adj[u]){
      |                      ^
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 312 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
6 Correct 1 ms 320 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 312 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
6 Correct 1 ms 320 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 3 ms 596 KB Output is correct
10 Correct 1 ms 312 KB Output is correct
11 Correct 2 ms 340 KB Output is correct
12 Correct 5 ms 980 KB Output is correct
13 Correct 4 ms 832 KB Output is correct
14 Correct 1 ms 340 KB Output is correct
15 Correct 1 ms 340 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 312 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
6 Correct 1 ms 320 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 3 ms 596 KB Output is correct
10 Correct 1 ms 312 KB Output is correct
11 Correct 2 ms 340 KB Output is correct
12 Correct 5 ms 980 KB Output is correct
13 Correct 4 ms 832 KB Output is correct
14 Correct 1 ms 340 KB Output is correct
15 Correct 1 ms 340 KB Output is correct
16 Correct 427 ms 62796 KB Output is correct
17 Correct 77 ms 13316 KB Output is correct
18 Correct 80 ms 14824 KB Output is correct
19 Correct 468 ms 66880 KB Output is correct
20 Correct 260 ms 47232 KB Output is correct
21 Correct 35 ms 5812 KB Output is correct
22 Correct 386 ms 44492 KB Output is correct