結果
問題 |
No.2753 鳩の巣原理
|
ユーザー |
![]() |
提出日時 | 2024-05-10 22:38:18 |
言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 27 ms / 2,000 ms |
コード長 | 767 bytes |
コンパイル時間 | 972 ms |
コンパイル使用メモリ | 77,656 KB |
実行使用メモリ | 25,220 KB |
平均クエリ数 | 11.00 |
最終ジャッジ日時 | 2024-12-20 06:33:18 |
合計ジャッジ時間 | 3,571 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 30 |
ソースコード
#include <iostream> using namespace std; int main() { cin.tie(0); ios::sync_with_stdio(false); int ask = 0; auto rec = [&](auto &&self, int il, int nl, int ir, int nr) -> void { if (il + 1 == ir) { while (ask < 10) { ++ask; cout << "? 1" << endl; } cout << "Yes " << il << ' ' << ir << endl; exit(0); } ++ask; const int ic = (il + ir) / 2; cout << "? " << ic << endl; int resp = 0; cin >> resp; if (resp - nl < ic - il) { self(self, il, nl, ic, resp); } else { self(self, ic, resp, ir, nr); } }; int N; cin >> N; rec(rec, 1, 1, N, N - 1); }