結果

問題 No.2709 1975 Powers
ユーザー konchakoncha
提出日時 2024-03-31 14:29:42
言語 PyPy3
(7.3.15)
結果
TLE  
実行時間 -
コード長 1,011 bytes
コンパイル時間 157 ms
コンパイル使用メモリ 81,700 KB
実行使用メモリ 78,340 KB
最終ジャッジ日時 2024-03-31 14:29:59
合計ジャッジ時間 7,656 ms
ジャッジサーバーID
(参考情報)
judge12 / judge10
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 41 ms
55,604 KB
testcase_01 AC 41 ms
55,604 KB
testcase_02 AC 244 ms
72,888 KB
testcase_03 AC 132 ms
76,224 KB
testcase_04 AC 550 ms
76,416 KB
testcase_05 AC 130 ms
76,216 KB
testcase_06 AC 131 ms
76,492 KB
testcase_07 AC 53 ms
63,928 KB
testcase_08 TLE -
testcase_09 AC 250 ms
76,344 KB
testcase_10 TLE -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

from collections import Counter

def maker(l, x):
    while True:
        current = (l[-1]*x) % P
        for i, item in enumerate(l):
            if item == current:
                return (l[:i], l[i:])
        l.append(current)


N, P, Q = map(int, input().split())
A = list(map(int, input().split()))

A.sort()

lo = []
for x in [10, 9, 7, 5]:
    loops = maker([x%P], x)
    lo.append([])

    for a in A:
        a -= 1
        if len(loops[0]) > a:
            lo[-1].append(loops[0][a])
        a -= len(loops[0])
        lo[-1].append(loops[1][a%len(loops[1])])

clo = [Counter(l) for l in lo]
answer = 0

clo3 = clo[3]

for i in range(N):
    x = lo[0][i]
    clo3[lo[3][i]] -= 1

    for j in range(i+1, N):
        clo3[lo[3][j]] -= 1
        for k in range(j+1, N):
            clo3[lo[3][k]] -= 1
            answer += clo3.get((Q-(x+lo[1][j]+lo[2][k])) % P, 0)

        for k in range(j+1, N):
            clo3[lo[3][k]] += 1
    for j in range(i+1, N):
        clo3[lo[3][j]] += 1
print(answer)
0