250x250
Notice
Recent Posts
Recent Comments
Link
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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 |
Tags
- BFS
- 완전탐색
- englishbook
- STUDYENGLISH
- 알고리즘
- sw expert
- PyQt
- 원서
- 코테 준비
- sw expert academy
- dfs
- D4
- the midnight library
- 백준
- swexpertacademy
- 쉬운 알고리즘 문제
- 삼성
- nightroutine
- SQL
- 원서읽기
- 직무면접
- 코테 대비
- 코테
- readingbook
- 프로그래머스
- 코딩테스트
- 원서읽자
- English
- MySQL
- 알고리즘 문제
Archives
- Today
- Total
시나브로
[D6] 1263. [S/W 문제해결 응용] 8일차 - 사람 네트워크2 본문
728x90
#include <stdio.h>
#include <stdlib.h>
#include <string>
using namespace std;
int graph[1020][1020] = { 0 };
int main(void) {
int test_case = 0;
scanf("%d", &test_case);
for (int i = 0; i < test_case; i++) {
int person_number = 0;
scanf("%d", &person_number);
for (int n = 0; n < person_number; n++) {
for (int m = 0; m < person_number; m++) {
scanf("%d", &graph[n][m]);
if (graph[n][m] == 0)
graph[n][m] = 100000;
if (n == m)
graph[n][m] = 0;
}
}
for (int k = 0; k < person_number; k++)
for (int i =0; i < person_number; i++)
for (int j = 0; j < person_number; j++)
if (graph[i][k] + graph[k][j] < graph[i][j]) {
graph[i][j] = graph[i][k] + graph[k][j];
}
int min = 100000;
for (int n = 0; n < person_number; n++) {
int box = 0;
for (int m = 0; m < person_number; m++) {
if(n!=m)
box += graph[n][m];
}
if (min > box)
min = box;
}
printf("#%d %d\n",i+1, min);
}
return 0;
}
728x90
'알고리즘 > SW Expert Academy' 카테고리의 다른 글
[D4] 7829. 보물왕 태혁 (0) | 2019.10.06 |
---|---|
[D5] 7812. 옥희의 OK! 부동산 (0) | 2019.10.06 |
[D5] 1256. [S/W 문제해결 응용] 6일차 - K번째 접미어 (0) | 2019.10.06 |
[D4] 5432. 쇠막대기 자르기 (0) | 2019.10.06 |
[D3] 5356. 의석이의 세로로 말해요 (0) | 2019.10.06 |