Submission #630410

# Submission time Handle Problem Language Result Execution time Memory
630410 2022-08-16T10:34:39 Z NintsiChkhaidze Crocodile's Underground City (IOI11_crocodile) C++14
89 / 100
472 ms 63284 KB
#include "crocodile.h"
#include <bits/stdc++.h>
using namespace std;
#define s second
#define pb push_back
#define f first
 
const int nn = 100005;
vector <pair<int,int> > v[nn];
pair<int,int> dis[nn];
bool vis[nn];

// int R[nn][4],L[nn],P[nn];
// int main (){
//     int N,M,K;
//     cin>>N>>M>>K;
    
int travel_plan(int N, int M, int R[][2], int L[], int K, int P[]){
 
    for (int i = 0; i < M; i++){
        v[R[i][0]].pb({R[i][1],L[i]});
        v[R[i][1]].pb({R[i][0],L[i]});
    }
    for (int i=0;i<N; i++)
        dis[i] = {1e9,1e9};

    using T = pair<int,int>;
    priority_queue <T, vector <T>, greater <T>> pq;
    for (int i = 0; i < K; i++)
        dis[P[i]] = {0,0},pq.push({0,P[i]});

    while(pq.size()){
        int d = pq.top().f,x = pq.top().s;
        pq.pop();
        if (d != dis[x].s) continue;
        vis[x] = 1;
        for (auto [to,w]: v[x]){
            if (vis[to]) continue;
            int vl = w + d;
            if (dis[to].f > vl) {
                dis[to].s = dis[to].f;
                dis[to].f = vl;
                pq.push({dis[to].s, to});
            }else if (dis[to].s > vl){
                dis[to].s = vl;
                pq.push({dis[to].s, to});
            }
            
        }
    }

    return dis[0].s;
}
 
 

Compilation message

crocodile.cpp: In function 'int travel_plan(int, int, int (*)[2], int*, int, int*)':
crocodile.cpp:37:19: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17'
   37 |         for (auto [to,w]: v[x]){
      |                   ^
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2644 KB Output is correct
2 Correct 2 ms 2664 KB Output is correct
3 Correct 2 ms 2668 KB Output is correct
4 Correct 3 ms 2772 KB Output is correct
5 Correct 2 ms 2644 KB Output is correct
6 Correct 3 ms 2644 KB Output is correct
7 Correct 3 ms 2644 KB Output is correct
8 Correct 3 ms 2644 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2644 KB Output is correct
2 Correct 2 ms 2664 KB Output is correct
3 Correct 2 ms 2668 KB Output is correct
4 Correct 3 ms 2772 KB Output is correct
5 Correct 2 ms 2644 KB Output is correct
6 Correct 3 ms 2644 KB Output is correct
7 Correct 3 ms 2644 KB Output is correct
8 Correct 3 ms 2644 KB Output is correct
9 Correct 3 ms 2900 KB Output is correct
10 Correct 2 ms 2676 KB Output is correct
11 Correct 2 ms 2772 KB Output is correct
12 Correct 4 ms 3164 KB Output is correct
13 Correct 4 ms 3156 KB Output is correct
14 Correct 2 ms 2644 KB Output is correct
15 Correct 2 ms 2772 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2644 KB Output is correct
2 Correct 2 ms 2664 KB Output is correct
3 Correct 2 ms 2668 KB Output is correct
4 Correct 3 ms 2772 KB Output is correct
5 Correct 2 ms 2644 KB Output is correct
6 Correct 3 ms 2644 KB Output is correct
7 Correct 3 ms 2644 KB Output is correct
8 Correct 3 ms 2644 KB Output is correct
9 Correct 3 ms 2900 KB Output is correct
10 Correct 2 ms 2676 KB Output is correct
11 Correct 2 ms 2772 KB Output is correct
12 Correct 4 ms 3164 KB Output is correct
13 Correct 4 ms 3156 KB Output is correct
14 Correct 2 ms 2644 KB Output is correct
15 Correct 2 ms 2772 KB Output is correct
16 Correct 378 ms 58300 KB Output is correct
17 Correct 78 ms 14924 KB Output is correct
18 Correct 112 ms 16436 KB Output is correct
19 Correct 472 ms 63284 KB Output is correct
20 Correct 260 ms 49552 KB Output is correct
21 Correct 35 ms 8116 KB Output is correct
22 Incorrect 276 ms 46388 KB Output isn't correct
23 Halted 0 ms 0 KB -