이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "crocodile.h"
#include<bits/stdc++.h>
#define MP make_pair
#define F first
#define S second
#define pb push_back
#define MEM(i,j) memset(i,j,sizeof i)
#define ET cout << "\n"
#define ALL(v) v.begin(),v.end()
#define DB(a,s,e) {for(int i=s;i<e;++i) cout << a[i] << " ";ET;}
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const ll INF=1e18;
vector<pll> G[100005];
pll dp[100005];
bitset<100005> vis;
int travel_plan(int N, int M, int R[][2], int L[], int K, int P[])
{
for(int i=0;i<N;++i)
dp[i]=MP(INF,INF);
for(int i=0;i<M;++i)
G[R[i][0]].pb(MP(L[i],R[i][1])),G[R[i][1]].pb(MP(L[i],R[i][0]));
for(int i=0;i<K;++i)
dp[P[i]]=MP(0,0);
for(int i=0;i<N;++i)
{
int mi=-1;
for(int j=0;j<N;++j)
if(!vis[j]&&(!~mi||dp[j].S<dp[mi].S))
mi=j;
vis[mi]=1;
for(auto j:G[mi])
if(!vis[j.S])
{
ll x=dp[mi].S+j.F;
if(x<dp[j.S].F)
dp[j.S].S=dp[j.S].F,dp[j.S].F=x;
else if(x<dp[j.S].S)
dp[j.S].S=x;
}
}
return dp[0].S;
}
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |