結果
| 問題 |
No.3018 目隠し宝探し
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2025-01-25 12:45:36 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 80 ms / 2,000 ms |
| コード長 | 626 bytes |
| コンパイル時間 | 1,024 ms |
| コンパイル使用メモリ | 67,328 KB |
| 実行使用メモリ | 25,972 KB |
| 平均クエリ数 | 2.59 |
| 最終ジャッジ日時 | 2025-01-25 22:20:02 |
| 合計ジャッジ時間 | 3,797 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge6 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 |
| other | AC * 21 |
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:21:21: warning: structured bindings only available with ‘-std=c++17’ or ‘-std=gnu++17’ [-Wc++17-extensions]
21 | auto[x,y]=ans[0];
| ^
main.cpp:28:17: warning: structured bindings only available with ‘-std=c++17’ or ‘-std=gnu++17’ [-Wc++17-extensions]
28 | for(auto[x,y]:ans)if((x-1)*(x-1)+(W-y)*(W-y)==d)
| ^
ソースコード
#include<iostream>
#include<vector>
#include<cassert>
using namespace std;
int main()
{
ios::sync_with_stdio(false);
cin.tie(nullptr);
int H,W;cin>>H>>W;
if(H==1&&W==1)
{
cout<<"! 1 1"<<endl;
return 0;
}
cout<<"? 1 1"<<endl;
int d;cin>>d;
vector<pair<int,int> >ans;
for(int x=1;x<=H;x++)for(int y=1;y<=W;y++)if((x-1)*(x-1)+(y-1)*(y-1)==d)ans.push_back(make_pair(x,y));
if(ans.size()==1)
{
auto[x,y]=ans[0];
cout<<"! "<<x<<" "<<y<<endl;
return 0;
}
assert(H>=2&&W>=2);
cout<<"? 1 "<<W<<endl;
cin>>d;
for(auto[x,y]:ans)if((x-1)*(x-1)+(W-y)*(W-y)==d)
{
cout<<"! "<<x<<" "<<y<<endl;
return 0;
}
}