답안 #543200

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
543200 2022-03-29T18:54:52 Z ogibogi2004 악어의 지하 도시 (IOI11_crocodile) C++14
100 / 100
510 ms 87892 KB
#include "crocodile.h"
#include<bits/stdc++.h>
using namespace std;
#define ll long long
const int MAXN=1e5+6;
const int INF=2e9;
vector<pair<int,ll> >g[MAXN];
bool winning[MAXN];
int wn_cnt[MAXN];
ll smol1[MAXN],smol2[MAXN];
bool used[MAXN];
int travel_plan(int N, int M, int R[][2], int L[], int K, int P[])
{

    for(int i=1;i<=N;i++)
    {
        winning[i]=0;
        wn_cnt[i]=0;
        smol1[i]=INF;
        smol2[i]=INF;
        used[i]=0;
    }
    for(int i=0;i<K;i++)
    {
        winning[P[i]+1]=1;
        smol1[P[i]+1]=0;
        smol2[P[i]+1]=0;
    }
    for(int i=0;i<M;i++)
    {
        g[R[i][0]+1].push_back({R[i][1]+1,L[i]});
        g[R[i][1]+1].push_back({R[i][0]+1,L[i]});
    }
    priority_queue<pair<int,int> >pq;
    for(int i=0;i<K;i++)
    {
        pq.push({-smol2[P[i]+1],P[i]+1});
    }
    while(!pq.empty())
    {
        int u=pq.top().second;
        pq.pop();
        if(used[u])continue;
        used[u]=1;
        if(u==0)break;
        for(auto xd:g[u])
        {
            wn_cnt[xd.first]++;
            if(smol2[u]+xd.second<=smol1[xd.first])
            {
                smol2[xd.first]=smol1[xd.first];
                smol1[xd.first]=smol2[u]+xd.second;
                if(smol2[xd.first]!=INF)pq.push({-smol2[xd.first],xd.first});
            }
            else if(smol2[u]+xd.second<smol2[xd.first])
            {
                smol2[xd.first]=smol2[u]+xd.second;
                pq.push({-smol2[xd.first],xd.first});
            }
        }
    }
    return smol2[1];
}
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 2644 KB Output is correct
2 Correct 2 ms 2644 KB Output is correct
3 Correct 2 ms 2644 KB Output is correct
4 Correct 2 ms 2772 KB Output is correct
5 Correct 2 ms 2772 KB Output is correct
6 Correct 2 ms 2772 KB Output is correct
7 Correct 2 ms 2772 KB Output is correct
8 Correct 2 ms 2772 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 2644 KB Output is correct
2 Correct 2 ms 2644 KB Output is correct
3 Correct 2 ms 2644 KB Output is correct
4 Correct 2 ms 2772 KB Output is correct
5 Correct 2 ms 2772 KB Output is correct
6 Correct 2 ms 2772 KB Output is correct
7 Correct 2 ms 2772 KB Output is correct
8 Correct 2 ms 2772 KB Output is correct
9 Correct 3 ms 3028 KB Output is correct
10 Correct 2 ms 2772 KB Output is correct
11 Correct 3 ms 2772 KB Output is correct
12 Correct 5 ms 3412 KB Output is correct
13 Correct 5 ms 3412 KB Output is correct
14 Correct 2 ms 2644 KB Output is correct
15 Correct 2 ms 2808 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 2644 KB Output is correct
2 Correct 2 ms 2644 KB Output is correct
3 Correct 2 ms 2644 KB Output is correct
4 Correct 2 ms 2772 KB Output is correct
5 Correct 2 ms 2772 KB Output is correct
6 Correct 2 ms 2772 KB Output is correct
7 Correct 2 ms 2772 KB Output is correct
8 Correct 2 ms 2772 KB Output is correct
9 Correct 3 ms 3028 KB Output is correct
10 Correct 2 ms 2772 KB Output is correct
11 Correct 3 ms 2772 KB Output is correct
12 Correct 5 ms 3412 KB Output is correct
13 Correct 5 ms 3412 KB Output is correct
14 Correct 2 ms 2644 KB Output is correct
15 Correct 2 ms 2808 KB Output is correct
16 Correct 432 ms 82256 KB Output is correct
17 Correct 83 ms 18140 KB Output is correct
18 Correct 94 ms 20600 KB Output is correct
19 Correct 510 ms 87892 KB Output is correct
20 Correct 258 ms 68044 KB Output is correct
21 Correct 33 ms 9932 KB Output is correct
22 Correct 260 ms 64284 KB Output is correct