# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
336888 | enerelt14 | Crocodile's Underground City (IOI11_crocodile) | C++14 | 13 ms | 5356 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "crocodile.h"
#include<bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
using namespace std;
vector<pair<int, int> >adj[100005];
int a[100005][3], s[100005]={0}, path;
bool is[100005]={0};
int dijkstra(int k){
bool vis[100005];
priority_queue<pair<int, int> >pq;
pq.push(mp(0, k));
while(!pq.empty()){
int u = pq.top().ss;
int cost = -pq.top().ff;
if (s[u]>=2)path=min(path,cost+a[u][2]);
pq.pop();
vis[u] = 1;
for(int i = 0; i < adj[u].size(); i++){
int v = adj[u][i].ff;
int e = adj[u][i].ss;
if(!(vis[v] && is[v])) pq.push(mp(-(cost + e), v));
}
while(!pq.empty() && vis[pq.top().ss]) pq.pop();
}
}
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]].pb(mp(R[i][1], L[i]));
adj[R[i][1]].pb(mp(R[i][0], L[i]));
}
for (int i=0;i<K;i++){
for (int j=0;j<adj[P[i]].size();j++){
int v=adj[P[i]][j].ff;
is[v]=1;
int cost=adj[P[i]][j].ss;
s[v]++;
if (s[v]==1)a[v][1]=cost;
if (s[v]==2){
a[v][2]=max(a[v][1], cost);
a[v][1]=min(a[v][1], cost);
}
if (s[v]>=3){
if (cost<a[v][1]){
a[v][2]=a[v][1];
a[v][1]=cost;
}
if (cost>=a[v][1] && cost<a[v][2])a[v][2]=cost;
}
}
}
path=1000000001;
dijkstra(0);
return path;
}
컴파일 시 표준 에러 (stderr) 메시지
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |