답안 #905131

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
905131 2024-01-12T15:45:11 Z Macker 악어의 지하 도시 (IOI11_crocodile) C++14
100 / 100
555 ms 69712 KB
#include "crocodile.h"
#include <bits/stdc++.h>
 
using namespace std;
typedef long long ll;
typedef long double ld;
#define all(v) v.begin(), v.end()

//#pragma GCC optimize("Ofast")
//#pragma GCC target("avx2")


int travel_plan(int N, int M, int R[][2], int L[], int K, int P[])
{
    vector<vector<pair<int, int>>> adj(N);
    vector<bool> bl(N, 0);
    vector<int> dist(N, INT_MAX/2);
    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]});
    }

    priority_queue<pair<int, int>, vector<pair<int, int>>, greater<pair<int, int>>> q;
    for (int i = 0; i < K; i++) {
        q.push({0, P[i]});
        bl[P[i]] = 1;
    }
    
    while(q.size()){
        auto [d, a] = q.top(); q.pop();
        if(!bl[a]){
            bl[a] = 1;
            continue;
        }
        if(d < dist[a]){
            dist[a] = d;
            for (auto &[b, c] : adj[a]) {
                if(dist[b] > dist[a] + c){
                    //dist[b] = dist[a] + c;
                    q.push({dist[a] + c, b});
                }
            }
        }
    }
    
    return dist[0];
}


Compilation message

crocodile.cpp: In function 'int travel_plan(int, int, int (*)[2], int*, int, int*)':
crocodile.cpp:30:14: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17'
   30 |         auto [d, a] = q.top(); q.pop();
      |              ^
crocodile.cpp:37:24: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17'
   37 |             for (auto &[b, c] : adj[a]) {
      |                        ^
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 4440 KB Output is correct
2 Correct 2 ms 4444 KB Output is correct
3 Correct 1 ms 4444 KB Output is correct
4 Correct 2 ms 4444 KB Output is correct
5 Correct 2 ms 4444 KB Output is correct
6 Correct 1 ms 4444 KB Output is correct
7 Correct 2 ms 4444 KB Output is correct
8 Correct 2 ms 4444 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 4440 KB Output is correct
2 Correct 2 ms 4444 KB Output is correct
3 Correct 1 ms 4444 KB Output is correct
4 Correct 2 ms 4444 KB Output is correct
5 Correct 2 ms 4444 KB Output is correct
6 Correct 1 ms 4444 KB Output is correct
7 Correct 2 ms 4444 KB Output is correct
8 Correct 2 ms 4444 KB Output is correct
9 Correct 3 ms 4700 KB Output is correct
10 Correct 2 ms 4444 KB Output is correct
11 Correct 2 ms 4444 KB Output is correct
12 Correct 5 ms 5064 KB Output is correct
13 Correct 5 ms 4956 KB Output is correct
14 Correct 1 ms 4444 KB Output is correct
15 Correct 2 ms 4444 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 4440 KB Output is correct
2 Correct 2 ms 4444 KB Output is correct
3 Correct 1 ms 4444 KB Output is correct
4 Correct 2 ms 4444 KB Output is correct
5 Correct 2 ms 4444 KB Output is correct
6 Correct 1 ms 4444 KB Output is correct
7 Correct 2 ms 4444 KB Output is correct
8 Correct 2 ms 4444 KB Output is correct
9 Correct 3 ms 4700 KB Output is correct
10 Correct 2 ms 4444 KB Output is correct
11 Correct 2 ms 4444 KB Output is correct
12 Correct 5 ms 5064 KB Output is correct
13 Correct 5 ms 4956 KB Output is correct
14 Correct 1 ms 4444 KB Output is correct
15 Correct 2 ms 4444 KB Output is correct
16 Correct 472 ms 64076 KB Output is correct
17 Correct 56 ms 15188 KB Output is correct
18 Correct 81 ms 16416 KB Output is correct
19 Correct 555 ms 69712 KB Output is correct
20 Correct 363 ms 57060 KB Output is correct
21 Correct 31 ms 9044 KB Output is correct
22 Correct 335 ms 46420 KB Output is correct