結果
| 問題 |
No.3018 目隠し宝探し
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2025-01-25 14:39:53 |
| 言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 2,422 bytes |
| コンパイル時間 | 3,422 ms |
| コンパイル使用メモリ | 281,556 KB |
| 実行使用メモリ | 25,972 KB |
| 平均クエリ数 | 2.86 |
| 最終ジャッジ日時 | 2025-01-25 23:25:03 |
| 合計ジャッジ時間 | 6,521 ms |
|
ジャッジサーバーID (参考情報) |
judge8 / judge9 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 |
| other | AC * 17 WA * 4 |
ソースコード
#include <bits/stdc++.h>
typedef long long ll;
typedef std::pair<long long, long long> P;
typedef std::priority_queue<P, std::vector<P>, std::greater<P>> PQ;
int main()
{
int h, w;
std::cin >> h >> w;
std::cout << "? 1 1" << std::endl;
ll d;
std::cin >> d;
std::vector<std::vector<bool>> grid(h + 1, std::vector<bool>(w + 1, false));
int count = 0;
int tempi = 0, tempj = 0;
for (int i = 1; i <= h; ++i) {
for (int j = 1; j <= w; ++j) {
if ((i - 1) * (i - 1) + (j - 1) * (j - 1) == d) {
count++;
tempi = i;
tempj = j;
grid[i][j] = true;
}
}
}
if (count == 1) {
std::cout << "! " << tempi << " " << tempj << std::endl;
return 0;
}
std::cout << "? " << h << " " << w << std::endl;
std::cin >> d;
count = 0;
tempi = 0, tempj = 0;
for (int i = 1; i <= h; ++i) {
for (int j = 1; j <= w; ++j) {
if (grid[i][j] && (h - i) * (h - i) + (w - j) * (w - j) == d) {
count++;
tempi = i;
tempj = j;
} else {
grid[i][j] = false;
}
}
}
if (count == 1) {
std::cout << "! " << tempi << " " << tempj << std::endl;
return 0;
}
std::cout << "? " << 1 << " " << w << std::endl;
std::cin >> d;
count = 0;
tempi = 0, tempj = 0;
for (int i = 1; i <= h; ++i) {
for (int j = 1; j <= w; ++j) {
if (grid[i][j] && (i - 1) * (i - 1) + (w - j) * (w - j) == d) {
count++;
tempi = i;
tempj = j;
} else {
grid[i][j] = false;
}
}
}
if (count == 1) {
std::cout << "! " << tempi << " " << tempj << std::endl;
return 0;
}
std::cout << "? " << h << " " << 1 << std::endl;
std::cin >> d;
count = 0;
tempi = 0, tempj = 0;
for (int i = 1; i <= h; ++i) {
for (int j = 1; j <= w; ++j) {
if (grid[i][j] && (h - i) * (h - i) + (1 - j) * (1 - j) == d) {
count++;
tempi = i;
tempj = j;
} else {
grid[i][j] = false;
}
}
}
if (count == 1) {
std::cout << "! " << tempi << " " << tempj << std::endl;
return 0;
}
}