結果

問題 No.1263 ご注文は数学ですか?
ユーザー kozykozy
提出日時 2020-10-12 18:12:43
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 70 ms / 2,000 ms
コード長 1,054 bytes
コンパイル時間 82 ms
コンパイル使用メモリ 10,836 KB
実行使用メモリ 8,380 KB
最終ジャッジ日時 2023-09-27 23:47:45
合計ジャッジ時間 815 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 13 ms
8,196 KB
testcase_01 AC 14 ms
8,364 KB
testcase_02 AC 14 ms
8,184 KB
testcase_03 AC 70 ms
8,380 KB
testcase_04 AC 22 ms
8,220 KB
testcase_05 AC 14 ms
8,328 KB
testcase_06 AC 14 ms
8,216 KB
testcase_07 AC 14 ms
8,260 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

def kokanzeta(L,hugou,ima,keisu):
    if len(L)==2:
        a,b=L
        if ima+" "+str(a)+" "+str(b) not in c:
            c[ima+" "+str(a)+" "+str(b)]=hugou*keisu/2
        else:
            c[ima+" "+str(a)+" "+str(b)]+=hugou*keisu/2
        if ima+" "+str(a+b) not in c:
            c[ima+" "+str(a+b)]=(-1)*hugou*keisu/2
        else:
            c[ima+" "+str(a+b)]+=(-1)*hugou*keisu/2
        return 1
    else:
        S=len(L)
        a=L[-1]
        K=[i for i in L]
        K=K[:-1]
        kokanzeta(K,hugou,ima+" "+str(a),keisu)
        for i in range(S-1):
            K=[i for i in L]
            K=K[:-1]
            K[i]+=a
            kokanzeta(K,hugou*(-1),ima,keisu)

#文字数ばれしないためにここで文字数を稼ぐ
mod=1000000007
x=int(input())
c=dict()
Q=[2]*x
kokanzeta(Q,1,str(),2)
p=list()
sc=list()
for i in c:
  s=i
  s="1"+s
  L=list(map(int,s.split()))
  L=L[1:]
  L=sorted(L)
  if L not in p:
    p.append(L)
    sc.append(c[i])
  else:
    sc[p.index(L)]+=c[i]
ans=1
for i in sc:
  ans*=int(i)
print(ans%mod)
0