Please sign in first.
提出 #71716570
ソースコード 拡げる
# 方針
# - x 座標と y 座標は独立で考えることができる
# - 1<=Ai<=10 と範囲が狭いので, collections.Counter でそれぞれの数字ごとの
# 出現回数を調べ, その数字によって到達できる座標を計算する
# - つぎにそれらを組み合わせて, 全体として到達できる座標を計算する
# - x-A[0] と y が, それぞれ到達可能な座標であれば Yes とする
from collections import Counter
N, x, y = map(int, input().split())
A = list(map(int, input().split()))
# x, y ごとに出現回数を数える
Xc = Counter([A[i] for i in range(2, N, 2)])
Yc = Counter([A[i] for i in range(1, N, 2)])
# 到達可能な座標を set で返す
def calc_dim(c: dict) -> set:
result = [set() for _ in range(len(c.keys())+1)]
result[0].add(0)
idx = 0
for i in c.keys():
# ひとつの Ai に対して到達できる座標を計算
lst = [(-c[i] + 2*j) * i for j in range(c[i]+1)]
# これまで到達できる座標 (result[idx]) に, 上記の座標を足す
for x in lst:
for p in result[idx]:
result[idx+1].add(p+x)
idx += 1
return result[idx]
# x, y に対して到達可能な座標を計算
Xs = calc_dim(Xc)
Ys = calc_dim(Yc)
# たどり着けるか?
if x-A[0] in Xs and y in Ys:
print("Yes")
else:
print("No")
提出情報
| 提出日時 | |
|---|---|
| 問題 | D - Robot Arms 2 |
| ユーザ | satomshr |
| 言語 | Python (PyPy 3.10-v7.3.12) |
| 得点 | 400 |
| コード長 | 1440 Byte |
| 結果 | AC |
| 実行時間 | 95 ms |
| メモリ | 82548 KiB |
ジャッジ結果
| セット名 | Sample | All | ||||
|---|---|---|---|---|---|---|
| 得点 / 配点 | 0 / 0 | 400 / 400 | ||||
| 結果 |
|
|
| セット名 | テストケース |
|---|---|
| Sample | 00_sample_00.txt, 00_sample_01.txt, 00_sample_02.txt, 00_sample_03.txt, 00_sample_04.txt |
| All | 00_sample_00.txt, 00_sample_01.txt, 00_sample_02.txt, 00_sample_03.txt, 00_sample_04.txt, 01_random_00.txt, 01_random_01.txt, 01_random_02.txt, 01_random_03.txt, 01_random_04.txt, 01_random_05.txt, 01_random_06.txt, 01_random_07.txt, 01_random_08.txt, 01_random_09.txt, 02_corner_00.txt, 02_corner_01.txt, 03_handmade_00.txt, 03_handmade_01.txt, 03_handmade_02.txt, 03_handmade_03.txt, 03_handmade_04.txt, 03_handmade_05.txt, 03_handmade_06.txt, 03_handmade_07.txt, 03_handmade_08.txt, 03_handmade_09.txt |
| ケース名 | 結果 | 実行時間 | メモリ |
|---|---|---|---|
| 00_sample_00.txt | AC | 70 ms | 76948 KiB |
| 00_sample_01.txt | AC | 69 ms | 76936 KiB |
| 00_sample_02.txt | AC | 71 ms | 76932 KiB |
| 00_sample_03.txt | AC | 70 ms | 76948 KiB |
| 00_sample_04.txt | AC | 71 ms | 76740 KiB |
| 01_random_00.txt | AC | 82 ms | 81176 KiB |
| 01_random_01.txt | AC | 95 ms | 82548 KiB |
| 01_random_02.txt | AC | 72 ms | 81376 KiB |
| 01_random_03.txt | AC | 89 ms | 81144 KiB |
| 01_random_04.txt | AC | 83 ms | 81156 KiB |
| 01_random_05.txt | AC | 86 ms | 81324 KiB |
| 01_random_06.txt | AC | 76 ms | 81104 KiB |
| 01_random_07.txt | AC | 85 ms | 81388 KiB |
| 01_random_08.txt | AC | 73 ms | 81228 KiB |
| 01_random_09.txt | AC | 87 ms | 81196 KiB |
| 02_corner_00.txt | AC | 85 ms | 81540 KiB |
| 02_corner_01.txt | AC | 88 ms | 81384 KiB |
| 03_handmade_00.txt | AC | 75 ms | 81272 KiB |
| 03_handmade_01.txt | AC | 73 ms | 81252 KiB |
| 03_handmade_02.txt | AC | 70 ms | 76948 KiB |
| 03_handmade_03.txt | AC | 72 ms | 81268 KiB |
| 03_handmade_04.txt | AC | 79 ms | 81288 KiB |
| 03_handmade_05.txt | AC | 75 ms | 81368 KiB |
| 03_handmade_06.txt | AC | 75 ms | 81524 KiB |
| 03_handmade_07.txt | AC | 73 ms | 81176 KiB |
| 03_handmade_08.txt | AC | 69 ms | 76700 KiB |
| 03_handmade_09.txt | AC | 71 ms | 77080 KiB |