# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
582668 | 1ne | 악어의 지하 도시 (IOI11_crocodile) | C++14 | 2 ms | 468 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "crocodile.h"
#include <bits/stdc++.h>
using namespace std;
int travel_plan(int N, int M, int R[][2], int L[], int K, int P[])
{
vector<vector<pair<int,int>>>adj(N);
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]});
}
vector<bool>got(N,false);
for (int i = 0;i<K;++i)got[P[i]] = true;
vector<vector<long long>>dp(N,vector<long long>(2,1e9));
vector<bool>visited(N,false),in_cycle(N,false);
const long long maxn = 1e9;
vector<int>parent(N,-1);
function<long long(int)>dfs = [&](int u){
if (got[u])return 0LL;
if (visited[u]){
int y = u;
in_cycle[y] = true;
y = parent[y];
while(y!=u && y!=-1){
in_cycle[y] = true;
y = parent[y];
}
return dp[u][1];
}
if (in_cycle[u]){
return dp[u][1];
}
visited[u] = true;
for (auto x:adj[u]){
if (x.first == parent[u])continue;
parent[x.first] = u;
long long temp = dfs(x.first) + x.second;
parent[x.first] = -1;
if (temp < dp[u][0]){
dp[u][1] = dp[u][0];
dp[u][0] = temp;
}
else if (temp < dp[u][1]){
dp[u][1] = temp;
}
}
visited[u] = false;
return dp[u][1];
};
long long ans = dfs(0);
return ans;
}
컴파일 시 표준 에러 (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... |