이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
//
// main.cpp
// a.cpp
//
// Created by Juri Aljohani on 03/02/1444 AH.
//
//
// main.cpp
// a.cpp
//
// Created by Juri Aljohani on 03/02/1444 AH.
//
#ifndef _GLIBCXX_NO_ASSERT
#include <cassert>
#endif
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#if __cplusplus >= 201103L
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
#endif
// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#if __cplusplus >= 201103L
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif
// - - - - - -
// #include<bits/stdc++.h>
using namespace std;
#define int long long
vector<pair<int,int>>adj[200001];
int ans = 1e18;
int dij[5][100001];
int best[100001];
int bll[301][301];
signed main(){
int n,m; cin >> n >> m;
int s,t; cin >> s >> t;
int u,v; cin >> u >> v;
for(int i = 1; i <= n; i++){
for(int j = 1; j <= n; j++){
bll[i][j] = bll[j][i] = 1e18;
if(i == j) bll[i][j] = bll[j][i] = 0;
}
}
for(int i = 0; i < m; i++){
int a,b,c; cin >> a >> b >> c;
adj[a].push_back({b,c});
adj[b].push_back({a,c});
bll[a][b] = min(bll[a][b], c);
bll[b][a] = min(bll[b][a], c);
}
for(int i = 1; i <= n; i++){
for(int j = 1; j <= n; j++){
for(int k = 1; k <= n; k++){
if(bll[j][i] == 1e18 || bll[i][k] == 1e18) continue;
bll[j][k] = min(bll[j][k], bll[j][i] + bll[i][k]);
}
}
}
ans = min(ans,bll[u][v]);
for(int i = 1; i <= n; i++){
for(int j = 1; j <= n; j++){
if(bll[s][i] == 1e18 || bll[i][j] == 1e18 || bll[j][t] == 1e18) continue;
if(bll[s][i] + bll[i][j] + bll[j][t] == bll[s][t]){
ans = min(ans, bll[u][i] + bll[v][j]);
ans = min(ans, bll[u][j] + bll[v][i]);
}
}
}
cout << ans;
}
# | 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... |