From 9aa4b28a4550a80c80cd0195de4fc9f3dab08c43 Mon Sep 17 00:00:00 2001 From: songyc macbook Date: Fri, 23 Jan 2026 22:09:02 +0900 Subject: [PATCH] baekjoon 20260123 --- code_study/Baekjoon/python/10797.py | 1 + code_study/Baekjoon/python/9466.py | 38 +++++++++++++++++++++++++++++ 2 files changed, 39 insertions(+) create mode 100644 code_study/Baekjoon/python/10797.py create mode 100644 code_study/Baekjoon/python/9466.py diff --git a/code_study/Baekjoon/python/10797.py b/code_study/Baekjoon/python/10797.py new file mode 100644 index 0000000..ac39f0b --- /dev/null +++ b/code_study/Baekjoon/python/10797.py @@ -0,0 +1 @@ +print((lambda x : input().split().count(x))(input())) \ No newline at end of file diff --git a/code_study/Baekjoon/python/9466.py b/code_study/Baekjoon/python/9466.py new file mode 100644 index 0000000..3acfe8f --- /dev/null +++ b/code_study/Baekjoon/python/9466.py @@ -0,0 +1,38 @@ +import sys +sys.setrecursionlimit(10**6) +input = sys.stdin.readline + +ans = [] + +for t in range(int(input())) : + n, selet = int(input()), [0] + list(map(int, input().split())) + + visited = [False] * (n+1) + finished = [False] * (n+1) + ans.append(n) + + def dfs(now) : + visited[now] = True + next = selet[now] + + if not visited[next] : + dfs(next) + + else : + if not finished[next] : + temp = next + + while temp != now : + ans[t] -= 1 + temp = selet[temp] + + ans[t] -= 1 + + finished[now] = True + + for i in range(1, n+1) : + if not visited[i] : + dfs(i) + +print('\n'.join(list(map(str, ans)))) + \ No newline at end of file