[백준(BOJ) 15462번] The Bovine Shuffle 풀이
문제 : https://www.acmicpc.net/problem/15462 크기가 2 이상인 SCC 내 원소의 개수와 크기가 1이고 자기 자신을 가리키는 SCC 개수를 더해서 출력하면 된다. SCC 찾기는 Tarjan's algorithm을 사용하였다. #include #include #include #define MAX_N 100000 using namespace std; int dfsn[MAX_N + 1], scc[MAX_N + 1], r, c; vector vt[MAX_N + 1]; vector res; stack st; int dfs(int here) { dfsn[here] = ++c; int ret = dfsn[here]; st.push(here); for (int next : vt[here]..
PS
2020. 1. 23. 22:47