이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "dreaming.h"
#include <bits/stdc++.h>
#define fi first
#define se second
#define lo long long
#define inf 1000000009
#define md 1000000007
#define li 100005
#define mp make_pair
#define pb push_back
using namespace std;
int vis[li], mn,M[li], M2[li], node[li], ss;
vector< pair<int, int> > v[li];
void f(int x){
vis[x] = 1;
int t;
for(int i = 0;i < (int)v[x].size(); i ++){
int go = v[x][i].fi;
int knr = v[x][i].se;
if(vis[go] == 1) continue;
f(go);
t = M[go] + knr;
if(M[x] < t){
M2[x] = M[x];
M[x] = t;
node[x] = go;
}
else if(M2[x] < t){
M2[x] = t;
}
}
ss = max(ss, M[x] + M2[x]);
}
void g(int x, int p, int t){
mn = min(mn, max(M[x], t));
for(int i = 0;i < (int)v[x].size(); i ++){
int go = v[x][i].fi;
int knr = v[x][i].se;
if(go == p) continue;
int a = max(t, node[x] == go? M2[x]:M[x]);
g(go, x ,a + knr);
}
}
int travelTime(int n, int m, int l, int *A, int *B, int *T){
int t, x , xx, xxx;
for(int i = 0;i < m; i ++){
v[ A[i] ].pb(mp(B[i], T[i]));
v[ B[i] ].pb(mp(A[i], T[i]));
}
x = - inf, xx = - inf,xxx = - inf;
for(int i = 0; i < n; i ++){
if(vis[i] == 1) continue;
mn = 1e9;
f(i);
g(i, - 1, 0);
if(x < mn){
xxx = xx;
xx = x;
x = mn;
}
else if(xx < mn){
xxx = xx;
xx = mn;
}
else if(xxx < mn){
xxx = mn;
}
}
return max(ss, max(x + xx + l,xx + xxx + l + l));
}
컴파일 시 표준 에러 (stderr) 메시지
dreaming.cpp: In function 'int travelTime(int, int, int, int*, int*, int*)':
dreaming.cpp:45:6: warning: unused variable 't' [-Wunused-variable]
int t, x , xx, xxx;
^| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |