티스토리 뷰
백준 소스코드 [C++] 10159 저울
#include <iostream>
#include <algorithm>
#include <queue>
#include <string.h>
#include <limits.h>
#include <vector>
#include <math.h>
#include <stack>
#include <bitset>
#include <string>
#include <set>
#include <sstream>
#define all(v) v.begin(), v.end()
#define pii pair<int,int>
#define make_unique(v) v.erase(unique(v.begin(), v.end()), v.end())
typedef long long ll;
using namespace std;
int n,m,arr[100][100];
void floyd() {
for (int via = 0;via < n;via++)
for (int here = 0;here < n;here++)
for (int next = 0;next < n;next++)
if (arr[here][via] == 1 && arr[via][next] == 1)
arr[here][next] = 1;
}
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cin >> n;
cin >> m;
for (int i = 0;i < m;i++) {
int u, v;
cin >> u >> v;
arr[u - 1][v - 1] = 1;
}
floyd();
for (int i = 0;i < n;i++) {
int res = 0;
for (int j = 0;j < n;j++)
if (arr[i][j] == 0 && arr[j][i] == 0 && i != j) res++;
cout << res<<'\n';
}
return 0;
}
'백준' 카테고리의 다른 글
백준 소스코드 [C++] 4195 친구 네트워크 (0) | 2021.03.06 |
---|---|
백준 소스코드 [C++] 11780 플로이드 2 (0) | 2021.03.06 |
백준 소스코드 [C++] 2143 두 배열의 합 (0) | 2021.03.04 |
백준 소스코드 [C++] 2056 작업 (0) | 2021.03.03 |
백준 소스코드 [C++] 4056 스-스-스도쿠 (0) | 2021.03.02 |
댓글
공지사항
최근에 올라온 글
최근에 달린 댓글
- Total
- Today
- Yesterday
TAG
- WWDC16
- 네트워크 유량
- 부스트캠프 6기
- 최단경로문제
- 벨만포드 알고리즘
- WWDC17
- MeTal
- 포드 풀커슨 알고리즘
- 에드몬드 카프 알고리즘
- 강한 순환 참조
- observeOn
- WWDC21
- 최단경로 문제
- 네트워크 플로우
- test coverage
- IOS
- 최단경로 알고리즘
- 코딩대회
- WWDC19
- 최대 매칭
- 컴퓨터 추상화
- mach-o
- 벨만포드 시간복잡도
- rxswift
- HIG
- CPU와 Memory
- Testable
- 다익스트라 시간복잡도
- State Restoration
- CompositionalLayout
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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 |
글 보관함