結果
問題 | No.3018 目隠し宝探し |
ユーザー |
|
提出日時 | 2025-01-25 15:03:20 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,845 bytes |
コンパイル時間 | 7,048 ms |
コンパイル使用メモリ | 255,868 KB |
実行使用メモリ | 26,072 KB |
平均クエリ数 | 3.55 |
最終ジャッジ日時 | 2025-01-25 23:40:35 |
合計ジャッジ時間 | 8,487 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | WA * 1 |
other | AC * 2 WA * 13 RE * 6 |
ソースコード
#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)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;}}cout << "? " << H << " " << W << endl;cin >> a;if(a == 0)cout << "! " << H << " " << W << endl;// a = sqrt(a);rep(i,H)rep(j,W){if((H-i-1)*(H-i-1) + (W-j-1) * (W-j-1) - a)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;}}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;}}