이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "crocodile.h"
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define sz(s) (int)s.size()
#define fi first
#define se second
#define pii pair<int,int>
vector<pair<int,int>> adj[100010];
int n, m, dis[100010];
set<int> good;
bool vis[100010];
int dfs(int s, int p){
multiset<int> S; S.clear();
if(good.count(s)) return dis[s];
if(sz(adj[s])==1) return 1000000000;
//S.insert()
for(auto u : adj[s]){
if(u.fi==p) continue;
S.insert(dfs(u.fi,s));
}
S.erase(S.begin()); return *S.begin();
}
void dijkstra(int s){
for(int i = 0; i <= 100000; i++) dis[i]=1000000000;
dis[s] = 0;
priority_queue<pii,vector<pii>,greater<pii>> pq;
pq.push({0,s});
while(!pq.empty()){
int a = pq.top().se; pq.pop();
if(vis[a]) continue; vis[a] = 1;
for(auto u : adj[a]){
int b = u.fi, w = u.se;
if(dis[b]>dis[a]+w){
dis[b] = dis[a]+w;
pq.push({dis[b],b});
}
}
}
}
int travel_plan(int N, int M, int R[][2], int L[], int K, int P[])
{
n = N, m = M;
for(int i = 0; i < n; i++){
int a = R[i][0], b = R[i][1], c = L[i];
adj[a].pb({b,c}), adj[b].pb({a,c});
}
for(int i = 0; i < K; i++) good.insert(P[i]);
dijkstra(0); return dfs(0,-1);
}
컴파일 시 표준 에러 (stderr) 메시지
crocodile.cpp: In function 'void dijkstra(int)':
crocodile.cpp:33:9: warning: this 'if' clause does not guard... [-Wmisleading-indentation]
33 | if(vis[a]) continue; vis[a] = 1;
| ^~
crocodile.cpp:33:30: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'if'
33 | if(vis[a]) continue; vis[a] = 1;
| ^~~
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |