結果
| 問題 | No.1349 Subset Product Queries |
| コンテスト | |
| ユーザー |
gew1fw
|
| 提出日時 | 2025-06-12 16:27:27 |
| 言語 | PyPy3 (7.3.17) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 2,283 bytes |
| 記録 | |
| コンパイル時間 | 229 ms |
| コンパイル使用メモリ | 95,724 KB |
| 実行使用メモリ | 160,384 KB |
| 最終ジャッジ日時 | 2026-07-11 16:43:16 |
| 合計ジャッジ時間 | 5,264 ms |
|
ジャッジサーバーID (参考情報) |
judge3_1 / judge2_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 |
| other | AC * 10 TLE * 1 -- * 19 |
ソースコード
def main():
import sys
input = sys.stdin.read().split()
ptr = 0
N = int(input[ptr])
ptr += 1
Q = int(input[ptr])
ptr += 1
P = int(input[ptr])
ptr += 1
A = list(map(int, input[ptr:ptr + N]))
ptr += N
output = []
for _ in range(Q):
L = int(input[ptr])
ptr += 1
R = int(input[ptr])
ptr += 1
K = int(input[ptr])
ptr += 1
if K == 0:
has_zero = False
for i in range(L-1, R):
if A[i] == 0:
has_zero = True
break
if has_zero:
output.append("Yes")
continue
current_bits = 0
found = False
for i in range(L-1, R):
a = A[i]
if a == 0:
continue
temp = current_bits
new_bits = 0
for r in range(P):
if (temp >> r) & 1:
new_r = (r * a) % P
new_bits |= 1 << new_r
new_bits |= 1 << a
current_bits |= new_bits
if (current_bits >> 0) & 1:
found = True
break
if found or (current_bits & 1):
output.append("Yes")
else:
output.append("No")
else:
current_bits = 0
found = False
for i in range(L-1, R):
a = A[i]
if a == 0:
continue
if a == K:
found = True
break
temp = current_bits
new_bits = 0
for r in range(P):
if (temp >> r) & 1:
new_r = (r * a) % P
new_bits |= 1 << new_r
new_bits |= 1 << a
current_bits |= new_bits
if (current_bits >> K) & 1:
found = True
break
if found:
output.append("Yes")
else:
output.append("No")
print('\n'.join(output))
if __name__ == '__main__':
main()
gew1fw