結果

問題 No.3018 目隠し宝探し
ユーザー はるはる
提出日時 2025-01-25 14:22:28
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 1,838 bytes
コンパイル時間 513 ms
コンパイル使用メモリ 82,048 KB
実行使用メモリ 77,312 KB
平均クエリ数 2.64
最終ジャッジ日時 2025-01-25 23:17:26
合計ジャッジ時間 4,382 ms
ジャッジサーバーID
(参考情報)
judge1 / judge6
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1
other AC * 20 WA * 1
権限があれば一括ダウンロードができます

ソースコード

diff #
プレゼンテーションモードにする

H,W=map(int,input().split())
if H==1 and W==1:
print("!",1,1)
elif H==1:
#
print("?",1,1)
d=int(input())
if d==-1:
exit()
for i in range(1,W+1):
if i*i==d:
print("!",1,i+1)
exit()
elif W==1:
#
print("?",1,1)
d=int(input())
if d==-1:
exit()
for i in range(1,H+1):
if i*i==d:
print("!",i+1,1)
exit()
else:
#2
print("?",1,1)
d1=int(input())
if d1==-1:
exit()
print("?",H,1)
d2=int(input())
if d2==-1:
exit()
ans_num=0
ans=0
for i in range(1,H+1):
for j in range(1,W+1):
if (i-1)*(i-1)+(j-1)*(j-1)==d1 and (i-H)*(i-H)+(j-1)*(j-1)==d2:
ans_num+=1
ans=[i,j]
if ans_num==1:
print("!",ans[0],ans[1])
exit()
else:
print("?",1,W)
d3=int(input())
if d3==-1:
exit()
ans_num=0
ans=0
for i in range(1,H+1):
for j in range(1,W+1):
if (i-1)*(i-1)+(j-1)*(j-1)==d1 and (i-H)*(i-H)+(j-1)*(j-1)==d2 and (i-1)*(i-1)+(j-W)*(j-W)==d3:
ans_num+=1
ans=[i,j]
if ans_num==1:
print("!",ans[0],ans[1])
exit()
else:
print("?",H,W)
d4=int(input())
if d4==-1:
exit()
ans_num=0
ans=0
for i in range(1,H+1):
for j in range(1,W+1):
if (i-1)*(i-1)+(j-1)*(j-1)==d1 and (i-H)*(i-H)+(j-1)*(j-1)==d2 and (i-1)*(i-1)+(j-W)*(j-W)==d3 and (i-H)*(i-H)+(j-W)*(j-W)==d4:
ans_num+=1
ans=[i,j]
print("!",ans[0],ans[1])
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
0