Submission #628228

# Submission time Handle Problem Language Result Execution time Memory
628228 2022-08-13T08:30:36 Z abcvuitunggio Crocodile's Underground City (IOI11_crocodile) C++17
100 / 100
498 ms 73028 KB
#include "crocodile.h"
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int travel_plan(int N, int M, int R[][2], int L[], int K, int P[]){
    ll INF=1e16,d[N][2];
    vector <pair <ll, ll> > ke[N];
    priority_queue<pair <ll, ll>, vector <pair <ll, ll> >, greater <pair <ll, ll> > > q;
    for (int i=0;i<M;i++)
        for (int j=0;j<2;j++)
            ke[R[i][j]].push_back({R[i][j^1],L[i]});
    for (int i=0;i<N;i++)
        d[i][0]=d[i][1]=INF;
    for (int i=0;i<K;i++){
        q.push({0,P[i]});
        d[P[i]][0]=d[P[i]][1]=0;
    }
    while (!q.empty()){
        ll u=q.top().second,du=q.top().first;
        q.pop();
        if (du!=d[u][1])
            continue;
        for (auto [v,w]:ke[u]){
            if (d[v][0]>d[u][1]+w){
                if (d[v][1]>d[v][0])
                    q.push({d[v][0],v});
                d[v][1]=d[v][0];
                d[v][0]=d[u][1]+w;
                continue;
            }
            if (d[v][1]>d[u][1]+w){
                d[v][1]=d[u][1]+w;
                q.push({d[v][1],v});
            }
        }
    }
    return d[0][1];
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 1 ms 340 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 340 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 1 ms 340 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 340 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 2 ms 596 KB Output is correct
10 Correct 0 ms 340 KB Output is correct
11 Correct 1 ms 468 KB Output is correct
12 Correct 4 ms 852 KB Output is correct
13 Correct 3 ms 980 KB Output is correct
14 Correct 1 ms 340 KB Output is correct
15 Correct 1 ms 340 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 1 ms 340 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 340 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 2 ms 596 KB Output is correct
10 Correct 0 ms 340 KB Output is correct
11 Correct 1 ms 468 KB Output is correct
12 Correct 4 ms 852 KB Output is correct
13 Correct 3 ms 980 KB Output is correct
14 Correct 1 ms 340 KB Output is correct
15 Correct 1 ms 340 KB Output is correct
16 Correct 389 ms 65424 KB Output is correct
17 Correct 70 ms 14368 KB Output is correct
18 Correct 86 ms 16616 KB Output is correct
19 Correct 498 ms 73028 KB Output is correct
20 Correct 252 ms 52684 KB Output is correct
21 Correct 32 ms 6596 KB Output is correct
22 Correct 276 ms 48240 KB Output is correct