티스토리 뷰
16064번: Coolest Ski Route
The input consists of: one line with two integers n (2 ≤ n ≤ 1000) and m (1 ≤ m ≤ 5000), where n is the number of (1-indexed) connecting points between slopes and m is the number of slopes. m lines, each with three integers s, t, c (1 ≤ s, t ≤
www.acmicpc.net
백준 소스코드 [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
- 에드몬드 카프 알고리즘
- WWDC21
- observeOn
- HIG
- 최단경로 문제
- CompositionalLayout
- test coverage
- 네트워크 플로우
- State Restoration
- 부스트캠프 6기
- 최대 매칭
- 벨만포드 알고리즘
- MeTal
- 강한 순환 참조
- 다익스트라 시간복잡도
- CPU와 Memory
- 최단경로문제
- rxswift
- Testable
- WWDC17
- 코딩대회
- IOS
- 포드 풀커슨 알고리즘
- 최단경로 알고리즘
- 컴퓨터 추상화
- WWDC16
- 벨만포드 시간복잡도
- WWDC19
- mach-o
- 네트워크 유량
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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 | 29 | 30 |
글 보관함