結果
| 問題 |
No.3018 目隠し宝探し
|
| ユーザー |
|
| 提出日時 | 2025-01-25 15:19:51 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 82 ms / 2,000 ms |
| コード長 | 2,259 bytes |
| コンパイル時間 | 4,468 ms |
| コンパイル使用メモリ | 256,704 KB |
| 実行使用メモリ | 25,972 KB |
| 平均クエリ数 | 2.73 |
| 最終ジャッジ日時 | 2025-01-25 23:44:19 |
| 合計ジャッジ時間 | 7,744 ms |
|
ジャッジサーバーID (参考情報) |
judge13 / judge7 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 |
| other | AC * 21 |
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:50:33: warning: ‘second_x’ may be used uninitialized [-Wmaybe-uninitialized]
50 | cout << "? " << second_x << " " << second_y << endl;
| ^~~
main.cpp:42:9: note: ‘second_x’ was declared here
42 | int second_x,second_y;
| ^~~~~~~~
main.cpp:50:40: warning: ‘second_y’ may be used uninitialized [-Wmaybe-uninitialized]
50 | cout << "? " << second_x << " " << second_y << endl;
| ^~~~~~~~
main.cpp:42:18: note: ‘second_y’ was declared here
42 | int second_x,second_y;
| ^~~~~~~~
ソースコード
#include <bits/stdc++.h>
#include <atcoder/all>
using namespace std;
using namespace atcoder;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
template <typename T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template <typename T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
int main() {
double H,W;
cin >> H >> W;
if(H == 1 && W == 1){
cout << "! 1 1" << endl;
return 0;
}
cout << "? 1 1" << endl;
double a;
cin >> a;
if(a == 0)cout << "! 1 1" << endl;
// a = sqrt(a);
vector<vector<bool>> res(H,vector<bool>(W,true));
int counter = H * W;
rep(i,H)rep(j,W){
if(i*i+j*j - a != 0){
res[i][j] = false;
counter--;
}
}
if(counter == 1){
rep(i,H)rep(j,W){
if(res[i][j]){
cout << "! " << i+1 << " " << j+1 << endl;
return 0;
}
}
}
int second_x,second_y;
rep(i,H)rep(j,W){
if(res[i][j]){
second_x = i + 1;
second_y = j + 1;
}
}
cout << "? " << second_x << " " << second_y << endl;
cin >> a;
if(a == 0)cout << "! " << second_x << " " << second_y << endl;
// a = sqrt(a);
rep(i,H)rep(j,W){
if(((second_x-i-1)*(second_x-i-1) + (second_y-j-1) * (second_y-j-1) - a != 0) && (res[i][j] == true)){
res[i][j] = false;
counter--;
}
}
if(counter == 1){
// cout << counter << endl;
rep(i,H)rep(j,W){
if(res[i][j]){
cout << "! " << i+1 << " " << j+1 << endl;
return 0;
}
}
}else{
vector<pair<int,int>> candidateList;
rep(i,H)rep(j,W){
if(res[i][j])candidateList.push_back({i+1,j+1});
}
// cout << candidateList.size() << endl;
cout << "? " << candidateList[0].first << " " << candidateList[0].second << endl;
cin >> a;
if(a)cout << "! " << candidateList[1].first << " " << candidateList[1].second << endl;
else cout << "! " << candidateList[0].first << " " << candidateList[0].second << endl;
}
}