답안 #341878

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
341878 2020-12-31T10:59:37 Z bigDuck 악어의 지하 도시 (IOI11_crocodile) C++14
100 / 100
1150 ms 68844 KB
#include "crocodile.h"
#include<bits/stdc++.h>
using namespace std;
#define INIT  ios_base :: sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#define mp make_pair
#define pb push_back
#define ft first
#define sc second
#define ll long long
#define pii pair<int, int>
#define count_bits __builtin_popcount
#define int ll

int p[100010], k;
vector<pii> g[100010];

bool v[100010];
int d[100010][2];

void tricky_dijkstra(){
multiset<pii> ms;

for(int i=1; i<=k; i++){
    ms.insert({0, p[i]});
    v[p[i]]=true;
}

while(!ms.empty()){
    auto pr=(*ms.begin()); ms.erase(ms.begin());
    int node=pr.sc, d0=pr.ft;
    v[node]=true;
    if(node==0){
        break;
    }
    for(auto pr:g[node]){
        int u=pr.ft, c=pr.sc;
        if(!v[u]){
            auto it=ms.find({d[u][1], u});
            if(it==ms.end()){
                if(d[u][0]==0){
                    d[u][0]=d0+c;
                }
                else{
                    d[u][1]=d0+c;
                    if(d[u][1]<d[u][0]){
                        swap(d[u][1], d[u][0]);
                    }
                    ms.insert({d[u][1], u});
                }
            }
            else{
                if( (d0+c)<d[u][1]  ){
                    d[u][1]=(d0+c);
                    if(d[u][1]<d[u][0]){
                        swap(d[u][1], d[u][0]);
                    }
                    ms.erase(it);
                    ms.insert({d[u][1], u});
                }
            }
        }
    }
}






}



int32_t travel_plan(int32_t N, int32_t M, int32_t R[][2], int32_t L[], int32_t K, int32_t P[]){

    k=K;
    for(int i=0; i<k; i++){
        p[i+1]=P[i];
    }

    for(int i=0; i<M; i++){
        int u=R[i][0], v=R[i][1], c=L[i];
        g[u].pb({v, c});
        g[v].pb({u, c});
    }
    tricky_dijkstra();
    return d[0][1];
}


# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 2668 KB Output is correct
2 Correct 2 ms 2668 KB Output is correct
3 Correct 2 ms 2796 KB Output is correct
4 Correct 3 ms 2796 KB Output is correct
5 Correct 3 ms 2796 KB Output is correct
6 Correct 2 ms 2796 KB Output is correct
7 Correct 3 ms 2796 KB Output is correct
8 Correct 3 ms 2796 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 2668 KB Output is correct
2 Correct 2 ms 2668 KB Output is correct
3 Correct 2 ms 2796 KB Output is correct
4 Correct 3 ms 2796 KB Output is correct
5 Correct 3 ms 2796 KB Output is correct
6 Correct 2 ms 2796 KB Output is correct
7 Correct 3 ms 2796 KB Output is correct
8 Correct 3 ms 2796 KB Output is correct
9 Correct 4 ms 3052 KB Output is correct
10 Correct 2 ms 2668 KB Output is correct
11 Correct 3 ms 2796 KB Output is correct
12 Correct 6 ms 3308 KB Output is correct
13 Correct 5 ms 3436 KB Output is correct
14 Correct 2 ms 2796 KB Output is correct
15 Correct 3 ms 2796 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 2668 KB Output is correct
2 Correct 2 ms 2668 KB Output is correct
3 Correct 2 ms 2796 KB Output is correct
4 Correct 3 ms 2796 KB Output is correct
5 Correct 3 ms 2796 KB Output is correct
6 Correct 2 ms 2796 KB Output is correct
7 Correct 3 ms 2796 KB Output is correct
8 Correct 3 ms 2796 KB Output is correct
9 Correct 4 ms 3052 KB Output is correct
10 Correct 2 ms 2668 KB Output is correct
11 Correct 3 ms 2796 KB Output is correct
12 Correct 6 ms 3308 KB Output is correct
13 Correct 5 ms 3436 KB Output is correct
14 Correct 2 ms 2796 KB Output is correct
15 Correct 3 ms 2796 KB Output is correct
16 Correct 955 ms 64796 KB Output is correct
17 Correct 94 ms 14572 KB Output is correct
18 Correct 120 ms 16940 KB Output is correct
19 Correct 1150 ms 68844 KB Output is correct
20 Correct 341 ms 55148 KB Output is correct
21 Correct 45 ms 8428 KB Output is correct
22 Correct 401 ms 50028 KB Output is correct