# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
932374 | salmon | Shortcut (IOI16_shortcut) | C++14 | 0 ms | 0 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "shortcut.h"
#include <bits/stdc++.h>
using namespace std;
queue<pair<int,int>> q;
long long int d[1100100];
long long find_shortcut(int N, vector<int> l, vector<int> d, int c){
long long int small = 1e18;
for(int i = 0; i < N; i++){
for(int j = i + 1; j < N; j++){
for(int k = 0; k < N; k++){
long long int big = 0;
for(int i = 0; i < N; i++){
d[i] = 1e18;
}
q.push(0,k);
d[k] = 0;
while(!q.empty()){
if(d[q.front().second] == q.front().first){
int m = q.front().second;
if(m == j){
if(d[m] + c < d[i]){
d[i] = d[m] + c;
q.push({d[i],i});
}
}
else if(m == i){
if(d[m] + c < d[j]){
d[j] = d[m] + c;
q.push({d[j],j});
}
}
if(m != N - 1){
if(d[m + 1] > d[m] + l[m]){
d[m + 1] = d[m] + l[m];
q.push({d[m + 1], m + 1});
}
}
if(m != 0){
if(d[m - 1] > d[m] + l[m - 1]){
d[m - 1] = d[m - 1] + l[m - 1];
q.push({d[m - 1], m - 1});
}
}
}
q.pop();
}
for(int i = 0; i < N; i++){
big = max(big,d[i]);
}
small = min(small,big);
}
}
}
return small;
}