結果
| 問題 | No.3579 区間積逆像 |
| コンテスト | |
| ユーザー |
titia
|
| 提出日時 | 2026-07-09 03:06:13 |
| 言語 | PyPy3 (7.3.17) |
| 結果 |
AC
|
| 実行時間 | 118 ms / 2,000 ms |
| コード長 | 994 bytes |
| 記録 | |
| コンパイル時間 | 1,737 ms |
| コンパイル使用メモリ | 95,600 KB |
| 実行使用メモリ | 122,648 KB |
| 最終ジャッジ日時 | 2026-07-09 03:09:08 |
| 合計ジャッジ時間 | 6,191 ms |
|
ジャッジサーバーID (参考情報) |
judge1_0 / judge2_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 30 |
ソースコード
import sys
input = sys.stdin.readline
from collections import Counter
N,P,C=list(map(int,input().split()))
A=list(map(int,input().split()))
Z=[]
for i in range(N):
if A[i]==0:
Z.append(i)
ANS=0
if C==0:
ind=0
for i in range(N):
if ind==len(Z):
break
if Z[ind]<i:
ind+=1
if ind==len(Z):
break
ANS+=N-Z[ind]
print(ANS)
else:
LIST=[]
X=[]
for i in range(N):
if A[i]==0:
if X!=[]:
LIST.append(X)
X=[]
else:
X=[]
else:
X.append(A[i])
if X!=[]:
LIST.append(X)
#print(LIST)
for L in LIST:
S=[1]
now=1
for x in L:
now=now*x%P
S.append(now)
CA=Counter(S)
for s in S:
CA[s]-=1
need=C*s%P
ANS+=CA[need]
#print(s,ANS,need)
print(ANS)
titia