Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

82-tgyuuAn #257

Merged
merged 2 commits into from
Dec 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions tgyuuAn/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,6 @@
| 51μ°¨μ‹œ | 2024.04.07 | BFS | <a href="https://www.acmicpc.net/problem/5213">과외맨</a> | https://github.com/AlgoLeadMe/AlgoLeadMe-1/pull/179
| 52μ°¨μ‹œ | 2024.05.06 | μœ„μƒμ •λ ¬ | <a href="https://www.acmicpc.net/problem/1516">κ²Œμž„ 개발</a> | https://github.com/AlgoLeadMe/AlgoLeadMe-1/pull/182
| 53μ°¨μ‹œ | 2024.05.09 | λ°±νŠΈλž˜ν‚Ή | <a href="https://www.acmicpc.net/problem/12100">2048 (Easy)</a> | https://github.com/AlgoLeadMe/AlgoLeadMe-1/pull/184
| 51μ°¨μ‹œ | 2024.04.07 | BFS | <a href="https://www.acmicpc.net/problem/5213">과외맨</a> | https://github.com/AlgoLeadMe/AlgoLeadMe-1/pull/179
| 52μ°¨μ‹œ | 2024.05.06 | μœ„μƒμ •λ ¬ | <a href="https://www.acmicpc.net/problem/1516">κ²Œμž„ 개발</a> | https://github.com/AlgoLeadMe/AlgoLeadMe-1/pull/182
| 53μ°¨μ‹œ | 2024.05.09 | λ°±νŠΈλž˜ν‚Ή | <a href="https://www.acmicpc.net/problem/12100">2048 (Easy)</a> | https://github.com/AlgoLeadMe/AlgoLeadMe-1/pull/184
| 54μ°¨μ‹œ | 2024.05.14 | λ‹€μ΅μŠ€νŠΈλΌ | <a href="https://www.acmicpc.net/problem/9370">미확인 도착지</a> | https://github.com/AlgoLeadMe/AlgoLeadMe-1/pull/185
| 55μ°¨μ‹œ | 2024.05.18 | μœ λ‹ˆμ˜¨ νŒŒμΈλ“œ | <a href="https://www.acmicpc.net/problem/4195">친ꡬ λ„€νŠΈμ›Œν¬</a> | https://github.com/AlgoLeadMe/AlgoLeadMe-1/pull/189
| 56μ°¨μ‹œ | 2024.05.18 | BFS | <a href="https://www.acmicpc.net/problem/17836">κ³΅μ£Όλ‹˜μ„ ꡬ해라!</a> | https://github.com/AlgoLeadMe/AlgoLeadMe-1/pull/193
Expand Down Expand Up @@ -88,4 +85,5 @@
| 79μ°¨μ‹œ | 2024.10.12 | 이뢄 맀칭 | <a href="https://www.acmicpc.net/problem/9576">μ±… λ‚˜λˆ μ£ΌκΈ°</a> | https://github.com/AlgoLeadMe/AlgoLeadMe-1/pull/251
| 80μ°¨μ‹œ | 2024.11.11 | λ‹€μ΅μŠ€νŠΈλΌ | <a href="https://www.acmicpc.net/problem/11779">μ΅œμ†ŒλΉ„μš© κ΅¬ν•˜κΈ° 2</a> | https://github.com/AlgoLeadMe/AlgoLeadMe-1/pull/254
| 81μ°¨μ‹œ | 2024.11.15 | 이뢄 탐색 | <a href="https://www.acmicpc.net/problem/1701">Cubeeditor</a> | https://github.com/AlgoLeadMe/AlgoLeadMe-1/pull/255
| 82μ°¨μ‹œ | 2024.11.22 | ν¬μ†Œ λ°°μ—΄ | <a href="https://www.acmicpc.net/problem/17435">ν•©μ„±ν•¨μˆ˜μ™€ 쿼리</a> | https://github.com/AlgoLeadMe/AlgoLeadMe-1/pull/257
---
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import sys

def input(): return sys.stdin.readline().rstrip()

M = int(input())
f_x = list(map(int, input().split()))

# ν¬μ†Œ λ°°μ—΄ μ΄ˆκΈ°ν™”
table = [[0] * (M + 1) for _ in range(30)]
table[0] = [0] + f_x # 첫 번째 레벨 μ΄ˆκΈ°ν™”

# ν¬μ†Œ λ°°μ—΄ μ±„μš°κΈ°
for i in range(1, 30): # 2^i 단계λ₯Ό 계산
for x in range(1, M + 1):
table[i][x] = table[i - 1][table[i - 1][x]]

# 쿼리 처리
Q = int(input())
for _ in range(Q):
N, X = map(int, input().split())
# N을 μ΄μ§„μˆ˜λ‘œ ν‘œν˜„ν•΄ ν•„μš”ν•œ λ‹¨κ³„λ§Œ μˆ˜ν–‰
for i in range(30):
if N & (1 << i): # i번째 λΉ„νŠΈκ°€ 1이라면
X = table[i][X]
print(X)