답안 #309301

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
309301 2020-10-03T07:20:40 Z amunduzbaev 악어의 지하 도시 (IOI11_crocodile) C++14
100 / 100
1444 ms 94644 KB
#include <bits/stdc++.h>
using namespace std;
#include "crocodile.h"
//#include "grader.cpp"

const int N1 = 2e5+5 ;
const int INF = 1e9+7 ;

vector<pair<int, int> > v[N1];
multiset<int> d[N1];
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]].push_back({r[i][1],l[i]});
        v[r[i][1]].push_back({r[i][0],l[i]});
    }
    set<pair<int,int>>q;
    for(int i=0;i<k;i++){
        d[p[i]].insert(0);
        d[p[i]].insert(0);
        q.insert({0,p[i]});
    }
    for(int i=0;i<n;i++){
        if(d[i].empty()) {
            d[i].insert(INF);
            d[i].insert(INF);
        }
    }

    while(!q.empty()){

        auto a=*q.begin();
        q.erase(q.begin());
        int dist=a.first;
        int ex=a.second;
        auto d1 = d[ex].begin();
        d1++;
        //cout<<dist<<" "<<ex<<" "<< *d1<<"\n";
        int D = *d1;
        if(D < dist) continue;

        for (auto x: v[ex]){
            int ver=x.first;
            int len=x.second;

            auto s=d[ver].begin();
            s++;
            if(D+len >= *s) continue;

            d[ver].insert(D+len);
            auto s1=d[ver].begin();
            s1++;
            if(*s1 < INF)
            q.insert({*s1,ver});

        }
    }
    auto ans=d[0].begin();
    ans++;
    int an=*ans;
    return an;
}


/*

5 7 2
0 2 4
0 3 3
3 2 2
2 1 10
0 1 100
0 4 7
3 4 9
1
3
14


*/
# 결과 실행 시간 메모리 Grader output
1 Correct 9 ms 14464 KB Output is correct
2 Correct 9 ms 14464 KB Output is correct
3 Correct 10 ms 14464 KB Output is correct
4 Correct 10 ms 14592 KB Output is correct
5 Correct 11 ms 14592 KB Output is correct
6 Correct 10 ms 14592 KB Output is correct
7 Correct 11 ms 14604 KB Output is correct
8 Correct 10 ms 14592 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 9 ms 14464 KB Output is correct
2 Correct 9 ms 14464 KB Output is correct
3 Correct 10 ms 14464 KB Output is correct
4 Correct 10 ms 14592 KB Output is correct
5 Correct 11 ms 14592 KB Output is correct
6 Correct 10 ms 14592 KB Output is correct
7 Correct 11 ms 14604 KB Output is correct
8 Correct 10 ms 14592 KB Output is correct
9 Correct 12 ms 14720 KB Output is correct
10 Correct 10 ms 14464 KB Output is correct
11 Correct 11 ms 14592 KB Output is correct
12 Correct 14 ms 14976 KB Output is correct
13 Correct 13 ms 14976 KB Output is correct
14 Correct 10 ms 14464 KB Output is correct
15 Correct 10 ms 14592 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 9 ms 14464 KB Output is correct
2 Correct 9 ms 14464 KB Output is correct
3 Correct 10 ms 14464 KB Output is correct
4 Correct 10 ms 14592 KB Output is correct
5 Correct 11 ms 14592 KB Output is correct
6 Correct 10 ms 14592 KB Output is correct
7 Correct 11 ms 14604 KB Output is correct
8 Correct 10 ms 14592 KB Output is correct
9 Correct 12 ms 14720 KB Output is correct
10 Correct 10 ms 14464 KB Output is correct
11 Correct 11 ms 14592 KB Output is correct
12 Correct 14 ms 14976 KB Output is correct
13 Correct 13 ms 14976 KB Output is correct
14 Correct 10 ms 14464 KB Output is correct
15 Correct 10 ms 14592 KB Output is correct
16 Correct 1027 ms 76792 KB Output is correct
17 Correct 136 ms 43512 KB Output is correct
18 Correct 192 ms 44536 KB Output is correct
19 Correct 1444 ms 94644 KB Output is correct
20 Correct 366 ms 57592 KB Output is correct
21 Correct 73 ms 25464 KB Output is correct
22 Correct 457 ms 63864 KB Output is correct