티스토리 뷰
백준 소스코드 [C++] 16064 Coolest Ski Route
#include <iostream>
#include <algorithm>
#include <queue>
#include <string.h>
#include <limits.h>
#include <vector>
typedef long long ll;
using namespace std;
#define MAX 987654321
int adj[1001][1001];
int V, E, u, v, w,res=0;
void floyd() {
for (int via = 1;via <= V;via++) {
for (int start = 1;start <= V;start++) {
if (adj[start][via] == MAX) continue;
for (int dest = 1;dest <= V;dest++) {
if (adj[via][dest] == MAX) continue;
if (adj[start][dest] > adj[start][via] + adj[via][dest])
{
adj[start][dest] = adj[start][via] + adj[via][dest];
res = min(res, adj[start][dest]);
}
}
}
}
}
int main() {
cin >> V >> E;
for (int start = 1;start <= V;start++)
for (int dest = 1;dest <= V;dest++)
adj[start][dest] = MAX;
for (int i = 1;i <= E;i++) {
cin >> u >> v >> w;
adj[u][v]=min(adj[u][v],-w);
res = min(res, adj[u][v]);
}
floyd();
cout << -res;
return 0;
}
'백준' 카테고리의 다른 글
백준 소스코드 [C++] 11375 열혈강호 (0) | 2020.09.12 |
---|---|
백준 소스코드 [C++] 2188 축사 배정 (0) | 2020.09.12 |
백준 소스코드 [C++] 2822 점수 계산 (0) | 2020.09.09 |
백준 소스코드 [C++] 11004 K번째 수 (0) | 2020.09.09 |
백준 소스코드 [C++] 10814 나이순 정렬 (0) | 2020.09.09 |
댓글
공지사항
최근에 올라온 글
최근에 달린 댓글
- Total
- Today
- Yesterday
TAG
- CPU와 Memory
- 최단경로 문제
- State Restoration
- WWDC16
- WWDC17
- Testable
- CompositionalLayout
- 네트워크 유량
- 에드몬드 카프 알고리즘
- 다익스트라 시간복잡도
- mach-o
- 최단경로 알고리즘
- 네트워크 플로우
- WWDC19
- 부스트캠프 6기
- 벨만포드 알고리즘
- MeTal
- 최단경로문제
- rxswift
- 강한 순환 참조
- IOS
- 벨만포드 시간복잡도
- 컴퓨터 추상화
- test coverage
- HIG
- WWDC21
- 포드 풀커슨 알고리즘
- 코딩대회
- observeOn
- 최대 매칭
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | ||||||
2 | 3 | 4 | 5 | 6 | 7 | 8 |
9 | 10 | 11 | 12 | 13 | 14 | 15 |
16 | 17 | 18 | 19 | 20 | 21 | 22 |
23 | 24 | 25 | 26 | 27 | 28 |
글 보관함