結果
| 問題 |
No.3018 目隠し宝探し
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2025-01-25 13:35:53 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
RE
|
| 実行時間 | - |
| コード長 | 1,597 bytes |
| コンパイル時間 | 2,195 ms |
| コンパイル使用メモリ | 198,284 KB |
| 実行使用メモリ | 26,356 KB |
| 平均クエリ数 | 2.68 |
| 最終ジャッジ日時 | 2025-01-25 22:51:29 |
| 合計ジャッジ時間 | 5,241 ms |
|
ジャッジサーバーID (参考情報) |
judge11 / judge9 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 |
| other | AC * 20 RE * 1 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main(){
ios::sync_with_stdio(false);
cin.tie(0);
int h, w, d;
cin >> h >> w;
cout << "? 1 1" << endl;
cin >> d;
vector<pair<int,int>> cand, cand2;
for(int y = 1; y <= h; y++){
for(int x = 1; x <= w; x++){
if((y - 1) * (y - 1) + (x - 1) * (x - 1) == d){
cand.emplace_back(y, x);
}
}
}
if(cand.size() == 1){
auto [y, x] = cand[0];
cout << "! " << y << ' ' << x << endl;
return 0;
}
if(h != 1){
cout << "? " << h << ' ' << 1 << endl;
cin >> d;
for(auto [y, x] : cand){
if((y - h) * (y - h) + (x - 1) * (x - 1) == d){
cand2.emplace_back(y, x);
}
}
}else{
cout << "? " << 1 << ' ' << w << endl;
cin >> d;
for(auto [y, x] : cand){
if((y - 1) * (y - 1) + (x - w) * (x - w) == d){
cand2.emplace_back(y, x);
}
}
}
swap(cand, cand2);
if(cand.size() == 1){
auto [y, x] = cand[0];
cout << "! " << y << ' ' << x << endl;
return 0;
}
cand2.clear();
cout << "? " << 1 << ' ' << w << endl;
cin >> d;
for(auto [y, x] : cand){
if((y - 1) * (y - 1) + (x - w) * (x - w) == d){
cand2.emplace_back(y, x);
}
}
swap(cand, cand2);
if(cand.size() == 1){
auto [y, x] = cand[0];
cout << "! " << y << ' ' << x << endl;
return 0;
}
assert(false);
}