이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "shortcut.h"
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
typedef long long ll;
typedef pair <int,int> ii;
ll maxi=100000000000000000;
ll best[3000];
ll ans=maxi;
vector <vector <ii> > graph;
void DFS(int node, ll dis=0)
{
best[node]=min(best[node],dis);
for(int i=0;i<graph[node].size();i++)
{
if(best[graph[node][i].second]>dis+graph[node][i].first)
{
DFS(graph[node][i].second,dis+graph[node][i].first);
}
}
}
long long find_shortcut(int n, std::vector<int> l, std::vector<int> d, int c)
{
graph=vector <vector <ii> > (2*n);
for(int i=0;i<n;i++)
{
if(i!=n-1)
{
graph[i].pb(ii(l[i],i+1));
graph[i+1].pb(ii(l[i],i));
}
graph[i].pb(ii(d[i],i+n));
graph[i+n].pb(ii(d[i],i));
}
for(int i=0;i<n;i++)
{
for(int j=i+1;j<n;j++)
{
graph[i].pb(ii(c,j));
graph[j].pb(ii(c,i));
ll maxii=0;
for(int k=0;k<2*n;k++)
{
for(int l=0;l<2*n;l++)
{
best[l]=maxi;
}
DFS(k);
for(int l=0;l<2*n;l++)
{
maxii=max(maxii,best[l]);
}
}
ans=min(ans,maxii);
graph[i].pop_back();
graph[j].pop_back();
}
}
return ans;
}
컴파일 시 표준 에러 (stderr) 메시지
shortcut.cpp: In function 'void DFS(int, ll)':
shortcut.cpp:30:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
30 | for(int i=0;i<graph[node].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... |
| # | 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... |