| 일 | 월 | 화 | 수 | 목 | 금 | 토 |
|---|---|---|---|---|---|---|
| 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 | 31 |
Tags
- dropout
- tensorflow
- 크루스칼
- back propagation
- 너비 우선 탐색
- 회고록
- DP
- 가끔은_말로
- BFS
- 알고리즘
- object detection
- 가끔은 말로
- 이분 탐색
- 2023
- Overfitting
- 조합론
- dfs
- 미래는_현재와_과거로
- 우선 순위 큐
- 자바스크립트
- 문자열
- c++
- 백트래킹
- 플로이드 와샬
- 다익스트라
- 세그먼트 트리
- 분할 정복
- lazy propagation
- pytorch
- NEXT
Archives
- Today
- Total
Doby's Lab
백준 11400번: 단절선 (C++) 본문
https://www.acmicpc.net/problem/11400
11400번: 단절선
첫째 줄에 두 정수 V(1≤V≤100,000), E(1≤E≤1,000,000)가 주어진다. 이는 그래프가 V개의 정점과 E개의 간선으로 이루어져 있다는 의미이다. 다음 E개의 줄에는 간선에 대한 정보를 나타내는 두 정수 A
www.acmicpc.net
Solved By: Articulation
직전 포스팅인 Articulation Point와 접점이 많습니다. Articulation Point에서 childOrder가 현재 node의 visitedOrder보다 큰 경우가 Articulation Edge가 되는 경우입니다.
#include <iostream>
#include <vector>
#define MAX 100001
#define pii pair<int, int>
using namespace std;
vector<int> adj[MAX];
int v, e;
vector<pii> isCut;
int order = 0;
int dfs(int now, int par){
int minOrder = visitedOrder[now] = ++order;
for(int i = 0; i < adj[now].size(); i++){
int next = adj[now][i];
// parent node에 접근할 경우 continue
if(next == par) continue;
if(visitedOrder[next]){
minOrder = min(minOrder, visitedOrder[next]);
continue;
}
int childOrder = dfs(next, now);
if(visitedOrder[now] < childOrder){
// 아직 방문 안 한 node의 visitedOrder가 현재 node의 visitedOrder보다
// 크다면 해당 edge는 Articulation이 된다.
// 같다는 되지 않는 이유가 해당 edge가 없어져도 현재 node로 올 수 있는
// edge가 있다는 뜻이다.
isCut.push_back({min(now, next), max(now, next)});
}
minOrder = min(minOrder, childOrder);
}
return minOrder;
}
int main(){
cin >> v >> e;
for(int i = 0; i < e; i++){
int a, b; cin >> a >> b;
adj[a].push_back(b);
adj[b].push_back(a);
}
for(int i = 1; i <= v; i++){
if(!visitedOrder[i]) dfs(i, 0);
}
}
'PS > BOJ' 카테고리의 다른 글
| 백준 23355번: 공사 (C++) (0) | 2022.06.03 |
|---|---|
| 백준 14675번: 단절점과 단절선 (C++) (2) | 2022.06.01 |
| 백준 11266번: 단절점 (C++) (0) | 2022.06.01 |
| 백준 3640번: 제독 (C++) (0) | 2022.06.01 |
| 백준 3679번: 단순 다각형 (C++) (0) | 2022.06.01 |
