結果
| 問題 |
No.2359 A in S ?
|
| コンテスト | |
| ユーザー |
lam6er
|
| 提出日時 | 2025-04-15 21:01:50 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,312 bytes |
| コンパイル時間 | 146 ms |
| コンパイル使用メモリ | 82,320 KB |
| 実行使用メモリ | 138,268 KB |
| 最終ジャッジ日時 | 2025-04-15 21:07:15 |
| 合計ジャッジ時間 | 4,282 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 1 WA * 1 TLE * 1 -- * 15 |
ソースコード
import sys
from collections import defaultdict
def main():
input = sys.stdin.read().split()
ptr = 0
N = int(input[ptr])
ptr += 1
M = int(input[ptr])
ptr += 1
B = int(10**5 ** 0.5) # Approximately 316
small_groups = defaultdict(list)
large_groups = defaultdict(list)
for _ in range(N):
L = int(input[ptr])
ptr += 1
R = int(input[ptr])
ptr += 1
X = int(input[ptr])
ptr += 1
Y = int(input[ptr])
ptr += 1
if X <= B:
key = (X, Y)
small_groups[key].append((L, R))
else:
key = Y
large_groups[key].append((X, L, R))
A = list(map(int, input[ptr:ptr+M]))
ptr += M
for a in A:
count = 0
# Check small X groups
for X in range(1, B + 1):
Y_val = a % X
key = (X, Y_val)
if key in small_groups:
for (L, R) in small_groups[key]:
if L <= a <= R:
count += 1
# Check large X groups
Y_val = a
if Y_val in large_groups:
for (X, L, R) in large_groups[Y_val]:
if X > B and L <= a <= R:
count += 1
print(count)
if __name__ == "__main__":
main()
lam6er