Submission #440617

# Submission time Handle Problem Language Result Execution time Memory
440617 2021-07-02T14:19:33 Z julian33 Crocodile's Underground City (IOI11_crocodile) C++14
100 / 100
603 ms 63604 KB
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

const int mxN=1e5+5,inf=1e9+10;

vector<pii> graph[mxN];

int dist[mxN][2],seen[mxN],n,m,k,a,b,w;

priority_queue<pii,vector<pii>, greater<pii> > q;

int travel_plan(int N, int M, int R[][2], int W[], int K, int E[]){
    int n=N;
    int m=M;
    int k=K;

    for(int i=0;i<n;i++) 
        dist[i][0]=dist[i][1]=inf;
    for(int i=0;i<m;i++){
        graph[R[i][0]].push_back(pii(R[i][1],W[i]));
        graph[R[i][1]].push_back(pii(R[i][0],W[i]));
    }
    for(int i=0;i<k;i++){
        q.push(pii(0,E[i]));
        dist[E[i]][1]=0;
    }
    while(!q.empty()){
        int at=q.top().second;
        q.pop();
        if(seen[at]) continue;
        seen[at]=true;
        for(pii &i:graph[at]){
            if(dist[at][1]+i.second < dist[i.first][1]){
                dist[i.first][1]=dist[at][1]+i.second;
                if(dist[i.first][1]<dist[i.first][0]) swap(dist[i.first][1],dist[i.first][0]);
                q.push(pii(dist[i.first][1],i.first));
            }
        }
    }
    return dist[0][1];
}
# Verdict Execution time Memory Grader output
1 Correct 2 ms 2636 KB Output is correct
2 Correct 2 ms 2636 KB Output is correct
3 Correct 2 ms 2636 KB Output is correct
4 Correct 2 ms 2672 KB Output is correct
5 Correct 2 ms 2764 KB Output is correct
6 Correct 2 ms 2636 KB Output is correct
7 Correct 2 ms 2636 KB Output is correct
8 Correct 2 ms 2764 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 2636 KB Output is correct
2 Correct 2 ms 2636 KB Output is correct
3 Correct 2 ms 2636 KB Output is correct
4 Correct 2 ms 2672 KB Output is correct
5 Correct 2 ms 2764 KB Output is correct
6 Correct 2 ms 2636 KB Output is correct
7 Correct 2 ms 2636 KB Output is correct
8 Correct 2 ms 2764 KB Output is correct
9 Correct 4 ms 2892 KB Output is correct
10 Correct 2 ms 2660 KB Output is correct
11 Correct 3 ms 2764 KB Output is correct
12 Correct 5 ms 3148 KB Output is correct
13 Correct 6 ms 3184 KB Output is correct
14 Correct 2 ms 2636 KB Output is correct
15 Correct 2 ms 2764 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 2636 KB Output is correct
2 Correct 2 ms 2636 KB Output is correct
3 Correct 2 ms 2636 KB Output is correct
4 Correct 2 ms 2672 KB Output is correct
5 Correct 2 ms 2764 KB Output is correct
6 Correct 2 ms 2636 KB Output is correct
7 Correct 2 ms 2636 KB Output is correct
8 Correct 2 ms 2764 KB Output is correct
9 Correct 4 ms 2892 KB Output is correct
10 Correct 2 ms 2660 KB Output is correct
11 Correct 3 ms 2764 KB Output is correct
12 Correct 5 ms 3148 KB Output is correct
13 Correct 6 ms 3184 KB Output is correct
14 Correct 2 ms 2636 KB Output is correct
15 Correct 2 ms 2764 KB Output is correct
16 Correct 461 ms 58400 KB Output is correct
17 Correct 105 ms 15132 KB Output is correct
18 Correct 119 ms 16764 KB Output is correct
19 Correct 603 ms 63604 KB Output is correct
20 Correct 297 ms 49604 KB Output is correct
21 Correct 45 ms 8092 KB Output is correct
22 Correct 326 ms 46404 KB Output is correct