# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
765324 | raysh07 | 악어의 지하 도시 (IOI11_crocodile) | C++17 | 409 ms | 76948 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "crocodile.h"
#include <bits/stdc++.h>
using namespace std;
#define INF (long long)(1e18 + 1)
#define int long long
int n, m;
const int maxn = 1e5 + 69;
vector <pair<int, int>> adj[maxn];
int dp[maxn][2];
int32_t travel_plan(int32_t N, int32_t M, int32_t R[][2], int32_t L[], int32_t K, int32_t P[])
{
n = N, m = M;
for (int i = 0; i < n; i++){
dp[i][0] = dp[i][1] = INF;
}
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 < K; i++){
dp[P[i]][0] = dp[P[i]][1] = 0;
}
//dp[i][0] = best path, dp[i][1] = second best path, update only with help of second best path values
priority_queue <pair<int, int>> pq;
for (int i = 0; i < n; i++){
if (dp[i][1] != INF)
pq.push({-dp[i][1], i});
}
while (!pq.empty()){
auto pi = pq.top();
pq.pop();
int d = -pi.first;
int u = pi.second;
if (d != dp[u][1]) continue;
for (pair <int, int> pi : adj[u]){
int v = pi.first;
int w = pi.second;
int val = d + w;
if (val < dp[v][0]){
int temp = dp[v][1];
dp[v][1] = dp[v][0];
dp[v][0] = val;
//if (dp[v][1] != temp)
pq.push({-dp[v][1], v});
} else if (val < dp[v][1]) {
dp[v][1] = val;
pq.push({-dp[v][1], v});
}
}
}
return dp[0][1];
}
컴파일 시 표준 에러 (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... |