Skip to content

Commit 33819b6

Browse files
authored
[BOJ] 1057 토너먼트 (S4)
1 parent 7ad46a1 commit 33819b6

File tree

1 file changed

+54
-0
lines changed

1 file changed

+54
-0
lines changed

김지호/6주차/260206.py

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
# https://www.acmicpc.net/problem/1057
2+
# 토너먼트, 실버4
3+
4+
import sys
5+
sys.stdin = open("../../../input.txt",'r')
6+
7+
N, x1,x2 = map(int,input().split(" "))
8+
9+
targets = [x1,x2]
10+
players = []
11+
for i in range(1,N+1):
12+
players.append(i)
13+
14+
step = 0
15+
isDone = False
16+
while not isDone:
17+
step += 1
18+
# print()
19+
# print(f"step : {step}")
20+
# print(f"players : {players}")
21+
22+
length = len(players)
23+
new_players = []
24+
for i in range(0,length,2):
25+
# 혼자 겨뤄
26+
if i == length-1:
27+
# print("마지막임")
28+
new_players.append(players[i])
29+
continue
30+
31+
# 정답 찾음
32+
if players[i] in targets and players[i+1] in targets:
33+
# print("정답 찾음")
34+
isDone = True
35+
break
36+
else:
37+
# 타겟이 있는 경우에는 이겨야 하고, 아니면 아무나 넣어
38+
if players[i] in targets:
39+
# print(f"1.타겟이 있음 : {players[i]}")
40+
new_players.append(players[i])
41+
elif players[i+1] in targets:
42+
# print(f"2.타겟이 있음 : {players[i+1]}")
43+
new_players.append(players[i+1])
44+
else:
45+
# print(f"3.타겟이 없음 : {players[i]}")
46+
new_players.append(players[i])
47+
# print(f"new players : {new_players}")
48+
players = new_players
49+
print(step)
50+
51+
52+
53+
54+

0 commit comments

Comments
 (0)