답안 #492928

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
492928 2021-12-09T18:48:44 Z Newtech66 악어의 지하 도시 (IOI11_crocodile) C++17
100 / 100
518 ms 72888 KB
#include "crocodile.h"
#include<bits/stdc++.h>
using namespace std;
using lol=long long int;
const lol inf=1e18+8;
 
int travel_plan(int N, int M, int R[][2], int L[], int K, int P[])
{
    vector<vector<pair<int,lol> > > g(N);
    for(int i=0;i<M;i++)
    {
        g[R[i][0]].push_back({R[i][1],L[i]});
        g[R[i][1]].push_back({R[i][0],L[i]});
    }
    priority_queue<pair<lol,int>,vector<pair<lol,int> >,greater<pair<lol,int> > > pq;
    vector<lol> mn(N,inf);
    vector<lol> smn(N,inf);
    for(int i=0;i<K;i++)
    {
        pq.push({0,P[i]});
        mn[P[i]]=smn[P[i]]=0;
    }
    while(!pq.empty())
    {
        auto [dist,u]=pq.top();
        pq.pop();
        if(dist>smn[u]) continue;
        for(auto [v,w]:g[u])
        {
            lol nxt=w+dist;
            if(nxt<=mn[v])
            {
                if(mn[v]<smn[v])
                {
                    smn[v]=mn[v];
                    mn[v]=nxt;
                    pq.push({smn[v],v});
                }else
                {
                    smn[v]=mn[v];
                    mn[v]=nxt;
                }
            }else if(nxt<smn[v])
            {
                smn[v]=nxt;
                pq.push({smn[v],v});
            }
        }
    }
    return smn[0];
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 1 ms 332 KB Output is correct
4 Correct 1 ms 332 KB Output is correct
5 Correct 1 ms 332 KB Output is correct
6 Correct 1 ms 332 KB Output is correct
7 Correct 1 ms 332 KB Output is correct
8 Correct 1 ms 332 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 1 ms 332 KB Output is correct
4 Correct 1 ms 332 KB Output is correct
5 Correct 1 ms 332 KB Output is correct
6 Correct 1 ms 332 KB Output is correct
7 Correct 1 ms 332 KB Output is correct
8 Correct 1 ms 332 KB Output is correct
9 Correct 3 ms 588 KB Output is correct
10 Correct 1 ms 332 KB Output is correct
11 Correct 1 ms 460 KB Output is correct
12 Correct 3 ms 844 KB Output is correct
13 Correct 3 ms 972 KB Output is correct
14 Correct 1 ms 332 KB Output is correct
15 Correct 1 ms 332 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 1 ms 332 KB Output is correct
4 Correct 1 ms 332 KB Output is correct
5 Correct 1 ms 332 KB Output is correct
6 Correct 1 ms 332 KB Output is correct
7 Correct 1 ms 332 KB Output is correct
8 Correct 1 ms 332 KB Output is correct
9 Correct 3 ms 588 KB Output is correct
10 Correct 1 ms 332 KB Output is correct
11 Correct 1 ms 460 KB Output is correct
12 Correct 3 ms 844 KB Output is correct
13 Correct 3 ms 972 KB Output is correct
14 Correct 1 ms 332 KB Output is correct
15 Correct 1 ms 332 KB Output is correct
16 Correct 413 ms 65440 KB Output is correct
17 Correct 71 ms 14344 KB Output is correct
18 Correct 88 ms 16668 KB Output is correct
19 Correct 518 ms 72888 KB Output is correct
20 Correct 273 ms 52732 KB Output is correct
21 Correct 33 ms 6636 KB Output is correct
22 Correct 273 ms 48252 KB Output is correct