이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "crocodile.h"
#include <bits/stdc++.h>
#define ll long long
#define INF 1000000000
using namespace std;
vector<vector<vector<ll>>> v;
vector<ll> vis, dp, isw;
void dfs(int x, ll co){
vis[x] = 1;
vector<ll> pus = {INF};
if (isw[x] == 1){
dp[x] = co;
return;
}
for (auto el : v[x]){
if (vis[el[1]] == 0){
dfs(el[1], co + el[0]);
pus.push_back(dp[el[1]]);
}
}
ll mi = INF, smi = INF;
for (int i = 0; i < pus.size(); i++){
if (pus[i] <= mi){
smi = mi;
mi = pus[i];
}
else if (pus[i] <= smi){
smi = pus[i];
}
}
dp[x] = smi;
}
int travel_plan(int N, int M, int R[][2], int L[], int K, int P[])
{
v.resize(N), vis.assign(N, 0), dp.assign(N, 0), isw.assign(N, 0);
for (int i = 0; i < M; i++){
v[R[i][0]].push_back({L[i], R[i][1]});
v[R[i][1]].push_back({L[i], R[i][0]});
}
for (int i = 0; i < N; i++){
dp[i] = 0;
sort(v[i].begin(), v[i].end());
}
for (int i = 0; i < K; i++){
isw[P[i]] = 1;
}
dfs(0, 0);
return dp[0];
}
컴파일 시 표준 에러 (stderr) 메시지
crocodile.cpp: In function 'void dfs(int, long long int)':
crocodile.cpp:22:21: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
22 | for (int i = 0; i < pus.size(); i++){
| ~~^~~~~~~~~~~~
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |