답안 #306069

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
306069 2020-09-24T12:31:17 Z vipghn2003 악어의 지하 도시 (IOI11_crocodile) C++14
89 / 100
795 ms 63976 KB
#include<bits/stdc++.h>
#define fi first
#define se second
#define pii pair<int,int>
#define mp make_pair
using namespace std;
const int N=1e5+5;
long long d[N][2];
vector<pii>adj[N];

int travel_plan(int N,int M,int R[][2],int L[],int K,int P[])
{
    for(int i=0;i<M;i++)
    {
        int u=R[i][0];
        int v=R[i][1];
        int w=L[i];
        adj[u].push_back(mp(v,w));
        adj[v].push_back(mp(u,w));
    }
    priority_queue<pair<int,long long>,vector<pair<int,long long>>,greater<pair<int,long long>>>pq;
    for(int i=0;i<N;i++) d[i][0]=d[i][1]=1e18;
    for(int i=0;i<K;i++)
    {
        d[P[i]][0]=d[P[i]][1]=0;
        pq.push(mp(0,P[i]));
    }
    while(!pq.empty())
    {
        int u=pq.top().se;
        long long dist=pq.top().fi;
        pq.pop();
        if(d[u][1]!=dist) continue;
        for(auto&v:adj[u])
        {
            long long ndist=dist+v.se;
            if(d[v.fi][0]>=ndist)
            {
                d[v.fi][1]=d[v.fi][0];
                d[v.fi][0]=ndist;
                pq.push(mp(d[v.fi][1],v.fi));
            }
            else if(d[v.fi][1]>ndist)
            {
                d[v.fi][1]=ndist;
                pq.push(mp(d[v.fi][1],v.fi));
            }
        }
    }
    return d[0][1];
}
/*
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    int n,m,k;
    cin>>n>>m>>k;
    int r[m][2],l[m],p[k];
    for(int i=0;i<m;i++) cin>>r[i][0]>>r[i][1];
    for(int i=0;i<m;i++) cin>>l[i];
    for(int i=0;i<k;i++) cin>>p[i];
    cout<<travel_plan(n,m,r,l,k,p);
}

5 4 3
0 1
0 2
3 2
2 4
2 3 1 4
1 3 4
*/
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 2688 KB Output is correct
2 Correct 3 ms 2688 KB Output is correct
3 Correct 3 ms 2688 KB Output is correct
4 Correct 3 ms 2816 KB Output is correct
5 Correct 3 ms 2816 KB Output is correct
6 Correct 3 ms 2688 KB Output is correct
7 Correct 3 ms 2816 KB Output is correct
8 Correct 3 ms 2816 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 2688 KB Output is correct
2 Correct 3 ms 2688 KB Output is correct
3 Correct 3 ms 2688 KB Output is correct
4 Correct 3 ms 2816 KB Output is correct
5 Correct 3 ms 2816 KB Output is correct
6 Correct 3 ms 2688 KB Output is correct
7 Correct 3 ms 2816 KB Output is correct
8 Correct 3 ms 2816 KB Output is correct
9 Correct 5 ms 2944 KB Output is correct
10 Correct 3 ms 2688 KB Output is correct
11 Correct 3 ms 2816 KB Output is correct
12 Correct 7 ms 3200 KB Output is correct
13 Correct 6 ms 3200 KB Output is correct
14 Correct 3 ms 2816 KB Output is correct
15 Correct 3 ms 2816 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 2688 KB Output is correct
2 Correct 3 ms 2688 KB Output is correct
3 Correct 3 ms 2688 KB Output is correct
4 Correct 3 ms 2816 KB Output is correct
5 Correct 3 ms 2816 KB Output is correct
6 Correct 3 ms 2688 KB Output is correct
7 Correct 3 ms 2816 KB Output is correct
8 Correct 3 ms 2816 KB Output is correct
9 Correct 5 ms 2944 KB Output is correct
10 Correct 3 ms 2688 KB Output is correct
11 Correct 3 ms 2816 KB Output is correct
12 Correct 7 ms 3200 KB Output is correct
13 Correct 6 ms 3200 KB Output is correct
14 Correct 3 ms 2816 KB Output is correct
15 Correct 3 ms 2816 KB Output is correct
16 Correct 625 ms 58384 KB Output is correct
17 Correct 103 ms 14584 KB Output is correct
18 Correct 129 ms 15992 KB Output is correct
19 Correct 795 ms 63976 KB Output is correct
20 Correct 377 ms 49656 KB Output is correct
21 Correct 49 ms 7928 KB Output is correct
22 Incorrect 410 ms 46392 KB Output isn't correct