답안 #1096126

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1096126 2024-10-03T21:09:28 Z I_FloPPed21 악어의 지하 도시 (IOI11_crocodile) C++14
89 / 100
361 ms 95168 KB
#include <bits/stdc++.h>
using namespace std;
const int N=2e5+1;
struct nod
{
    int unde;
    long long cost;
};

struct coada
{
    int unde;
    long long cost;
};

struct compare
{
    bool operator()(coada &x,coada &y)
    {
        return x.cost>y.cost;
    }
};
vector<nod>adj[N];
long long best[N][2];
int travel_plan(int n,int m,int r[][2],int l[],int k,int p[])
{
    for(int i=0;i<m;i++)
    {
        adj[r[i][0]].push_back({r[i][1],l[i]});
        adj[r[i][1]].push_back({r[i][0],l[i]});
    }


    for(int i=0;i<n;i++)
    {
        best[i][0]=best[i][1]=1e12+1;
    }
    priority_queue<coada,vector<coada>,compare>pq;
    for(int i=0;i<k;i++)
    {
        best[p[i]][0]=0;
        best[p[i]][1]=0;
        pq.push({p[i],0});
    }
    while(!pq.empty())
    {
        int nod=pq.top().unde;
        long long cost=pq.top().cost;
        pq.pop();
        if(cost!=best[nod][1])
            continue;
        for(auto u:adj[nod])
        {
            if(best[u.unde][0]>cost+u.cost)
            {
                best[u.unde][1]=best[u.unde][0];
                best[u.unde][0]=cost+u.cost;
                pq.push({u.unde,best[u.unde][1]});
            }
            else
                if(best[u.unde][1]>cost+u.cost)
            {
                best[u.unde][1]=cost+u.cost;
                pq.push({u.unde,best[u.unde][1]});
            }
        }
    }
    return best[0][1];
}

# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 4956 KB Output is correct
2 Correct 2 ms 5148 KB Output is correct
3 Correct 2 ms 4956 KB Output is correct
4 Correct 2 ms 5212 KB Output is correct
5 Correct 3 ms 5212 KB Output is correct
6 Correct 2 ms 5212 KB Output is correct
7 Correct 3 ms 5212 KB Output is correct
8 Correct 3 ms 5212 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 4956 KB Output is correct
2 Correct 2 ms 5148 KB Output is correct
3 Correct 2 ms 4956 KB Output is correct
4 Correct 2 ms 5212 KB Output is correct
5 Correct 3 ms 5212 KB Output is correct
6 Correct 2 ms 5212 KB Output is correct
7 Correct 3 ms 5212 KB Output is correct
8 Correct 3 ms 5212 KB Output is correct
9 Correct 3 ms 5468 KB Output is correct
10 Correct 2 ms 4952 KB Output is correct
11 Correct 3 ms 5208 KB Output is correct
12 Correct 4 ms 5724 KB Output is correct
13 Correct 4 ms 5976 KB Output is correct
14 Correct 2 ms 5212 KB Output is correct
15 Correct 3 ms 5212 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 4956 KB Output is correct
2 Correct 2 ms 5148 KB Output is correct
3 Correct 2 ms 4956 KB Output is correct
4 Correct 2 ms 5212 KB Output is correct
5 Correct 3 ms 5212 KB Output is correct
6 Correct 2 ms 5212 KB Output is correct
7 Correct 3 ms 5212 KB Output is correct
8 Correct 3 ms 5212 KB Output is correct
9 Correct 3 ms 5468 KB Output is correct
10 Correct 2 ms 4952 KB Output is correct
11 Correct 3 ms 5208 KB Output is correct
12 Correct 4 ms 5724 KB Output is correct
13 Correct 4 ms 5976 KB Output is correct
14 Correct 2 ms 5212 KB Output is correct
15 Correct 3 ms 5212 KB Output is correct
16 Correct 287 ms 86940 KB Output is correct
17 Correct 62 ms 22212 KB Output is correct
18 Correct 72 ms 24516 KB Output is correct
19 Correct 361 ms 95168 KB Output is correct
20 Correct 180 ms 70176 KB Output is correct
21 Correct 28 ms 12748 KB Output is correct
22 Incorrect 202 ms 66772 KB Output isn't correct
23 Halted 0 ms 0 KB -