結果
| 問題 | No.3627 Share the Median |
| コンテスト | |
| ユーザー |
👑 |
| 提出日時 | 2026-06-11 01:52:24 |
| 言語 | PyPy3 (7.3.17) |
| 結果 |
RE
|
| 実行時間 | - |
| コード長 | 1,607 bytes |
| 記録 | |
| コンパイル時間 | 241 ms |
| コンパイル使用メモリ | 95,460 KB |
| 実行使用メモリ | 93,900 KB |
| 平均クエリ数 | 1.00 |
| 最終ジャッジ日時 | 2026-08-14 20:51:34 |
| 合計ジャッジ時間 | 17,494 ms |
|
ジャッジサーバーID (参考情報) |
judge2_0 / judge3_0 |
(要ログイン)
| サブタスク | 配点 | 結果 |
|---|---|---|
| Sample | 0 % | |
| Easy | 20 % | RE * 16 |
| Hard | 80 % | RE * 24 |
| 合計 | 3 * 0% = 0 点 |
ソースコード
import sys
def read_line():
line = sys.stdin.readline()
if not line:
sys.exit(0)
return line
def read_ints_exact(length):
vals = []
while len(vals) < length:
vals.extend(map(int, read_line().split()))
return vals[:length]
def share_index(idx):
print(f"share {idx}", flush=True)
v = int(read_line())
if v == -1:
sys.exit(0)
return v
def answer_and_continue(ans):
print(f"answer {ans}", flush=True)
r = int(read_line())
if r == -1:
sys.exit(0)
def main():
T, Q = map(int, read_line().split())
player = read_line().strip()
is_alice = player == "Alice"
for _ in range(T):
N, M = map(int, read_line().split())
my_len = N if is_alice else M
other_len = M if is_alice else N
my = read_ints_exact(my_len)
other = []
rounds = max(N, M)
for r in range(1, rounds + 1):
if r <= my_len:
send_idx = r
else:
# 自分の列をすべて送り終えた後は、適当な有効 index を送る。
send_idx = 1
received = share_index(send_idx)
# r 回目に相手は r 番目を送っている。
# r > other_len のときは、相手もダミーを送っているだけなので無視する。
if r <= other_len:
other.append(received)
all_values = my + other
all_values.sort()
median = all_values[(N + M) // 2]
answer_and_continue(median)
if __name__ == "__main__":
main()