問題
ポイント
n = 3
for permutations_i in itertools.permutations((range(1, n+1))):
print(permutations_i)
(1, 2, 3)
(1, 3, 2)
(2, 1, 3)
(2, 3, 1)
(3, 1, 2)
(3, 2, 1)
解法
n=int(input())
p_list = tuple(list(map(int,input().split())))
q_list = tuple(list(map(int,input().split())))
import itertools
count = 0
for permutations_i in itertools.permutations((range(1, n+1))):
count += 1
if permutations_i == p_list:
count_p = count
if permutations_i == q_list:
count_q = count
print(abs(count_p - count_q))
感想
- ABC150のDは問題に不備があったとかなんとかだったのでCを載せます。