Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit f93303b

Browse files
Merge pull request #590 from JH-TT/BOJ_16986
인싸들의 가위바위보
2 parents 605f096 + 2872f9b commit f93303b

File tree

1 file changed

+42
-0
lines changed

1 file changed

+42
-0
lines changed

‎JongHo/BOJ/16986.py

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
import sys
2+
from itertools import permutations
3+
input = sys.stdin.readline
4+
5+
n, k = map(int, input().split())
6+
7+
info = [[0] * (n + 1)]
8+
for _ in range(n):
9+
hand = [0] + list(map(int, input().split()))
10+
info.append(hand)
11+
12+
kyung = list(map(int, input().split()))
13+
minho = list(map(int, input().split()))
14+
15+
def dfs(a, b, index, wins, P):
16+
if wins[0] == k:
17+
print(1)
18+
exit(0)
19+
20+
if index[0] == n:
21+
return
22+
23+
c = 3 - (a + b)
24+
p1 = P[a][index[a]]
25+
p2 = P[b][index[b]]
26+
index[a] += 1
27+
index[b] += 1
28+
29+
if info[p1][p2] == 2 or (info[p1][p2] == 1 and a > b):
30+
wins[a] += 1
31+
dfs(a, c, index, wins, P)
32+
elif (info[p1][p2] == 1 and a < b) or info[p1][p2] == 0:
33+
wins[b] += 1
34+
dfs(b, c, index, wins, P)
35+
36+
ziu = list(range(1, n+1))
37+
for i in permutations(ziu, n):
38+
P = [i, kyung, minho]
39+
index = [0, 0, 0]
40+
wins = [0, 0, 0]
41+
dfs(0, 1, index, wins, P)
42+
print(0)

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /