結果
| 問題 |
No.3018 目隠し宝探し
|
| コンテスト | |
| ユーザー |
tsunamayo123
|
| 提出日時 | 2025-01-25 13:38:19 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
RE
|
| 実行時間 | - |
| コード長 | 1,252 bytes |
| コンパイル時間 | 2,323 ms |
| コンパイル使用メモリ | 196,676 KB |
| 実行使用メモリ | 25,972 KB |
| 平均クエリ数 | 2.59 |
| 最終ジャッジ日時 | 2025-01-25 22:53:22 |
| 合計ジャッジ時間 | 5,135 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge9 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 |
| other | AC * 18 RE * 3 |
コンパイルメッセージ
main.cpp: In function ‘int question(int, int)’:
main.cpp:8:10: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
8 | scanf("%d",&d);
| ~~~~~^~~~~~~~~
ソースコード
#include<bits/stdc++.h>
using namespace std;
int question(int i,int j){
printf("? %d %d\n",i,j);
fflush(stdout);
int d;
scanf("%d",&d);
return d;
}
void answer(int i,int j){
printf("! %d %d\n",i,j);
fflush(stdout);
}
int main(){
int H,W; cin>>H>>W;
if(H==1&&W==1){
answer(1,1);
return 0;
}
int d1=question(1,1);
vector<pair<int,int>> D;
for(int i=1;i<=H;i++){
for(int j=1;j<=W;j++){
int dist1=(i-1)*(i-1)+(j-1)*(j-1);
if(dist1==d1){
D.push_back({i,j});
}
}
}
if(D.size()==1){
answer(D[0].first,D[0].second);
return 0;
}
D.clear();
int d2=question(H,W);
for(int i=1;i<=H;i++){
for(int j=1;j<=W;j++){
int dist1=(i-1)*(i-1)+(j-1)*(j-1);
int dist2=(i-H)*(i-H)+(j-W)*(j-W);
if(dist1==d1 && dist2==d2){
D.push_back({i,j});
}
}
}
if(D.size()==1){
answer(D[0].first,D[0].second);
return 0;
}
int d3=question(D[0].first,D[0].second);
if(d3==-1)return 1;
if(d3==0)answer(D[0].first,D[0].second);
else answer(D[1].first,D[1].second);
return 0;
}
tsunamayo123