結果
問題 | No.3018 目隠し宝探し |
ユーザー |
![]() |
提出日時 | 2025-01-25 15:57:34 |
言語 | C++17(gcc12) (gcc 12.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 103 ms / 2,000 ms |
コード長 | 1,553 bytes |
コンパイル時間 | 6,440 ms |
コンパイル使用メモリ | 253,792 KB |
実行使用メモリ | 25,984 KB |
平均クエリ数 | 2.64 |
最終ジャッジ日時 | 2025-01-25 23:50:02 |
合計ジャッジ時間 | 9,756 ms |
ジャッジサーバーID (参考情報) |
judge6 / judge13 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 |
other | AC * 21 |
コンパイルメッセージ
main.cpp: In function 'int main()': main.cpp:75:20: warning: 'x' may be used uninitialized [-Wmaybe-uninitialized] 75 | tmp1 -= (x - 1) * (x - 1); | ~~~^~~~ main.cpp:61:13: note: 'x' was declared here 61 | int x, y; | ^
ソースコード
#include <bits/stdc++.h>using namespace std;int main(){int H, W;cin >> H >> W;if (H * W == 1){cout << "! 1 1" << endl;return 0;}cout << "? 1 1" << endl;int tmp1;cin >> tmp1;if (tmp1 == 0){cout << "! 1 1" << endl;return 0;}if (H * W == 2){if (H == 1){cout << "! 1 2" << endl;return 0;}else{cout << "! 2 1" << endl;return 0;}}if (W == 1){for (int i = 1; i <= H; ++i){if (i * i == tmp1){cout << "! " << i + 1 << " 1" << endl;return 0;}}}else if (H == 1){for (int i = 1; i <= W; ++i){if (i * i == tmp1){cout << "! 1 " << i + 1 << endl;return 0;}}}else{cout << "? 1 2" << endl;int tmp2;cin >> tmp2;int sa = tmp1 - tmp2;int x, y;if (sa < 0)x = 1;else{for (int i = 1; i <= W; ++i){if (i * i - (i - 1) * (i - 1) == sa){x = i + 1;break;}}}tmp1 -= (x - 1) * (x - 1);tmp1 = sqrt(tmp1);cout << "! " << tmp1 + 1 << " " << x << endl;return 0;}}