We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
2 parents 605f096 + 2872f9b commit f93303bCopy full SHA for f93303b
JongHo/BOJ/16986.py
@@ -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)
AltStyle によって変換されたページ (->オリジナル) / アドレス: モード: デフォルト 音声ブラウザ ルビ付き 配色反転 文字拡大 モバイル
0 commit comments