結果

問題 No.2753 鳩の巣原理
ユーザー tour2st
提出日時 2024-05-10 22:43:48
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 26 ms / 2,000 ms
コード長 1,020 bytes
コンパイル時間 1,032 ms
コンパイル使用メモリ 108,472 KB
実行使用メモリ 25,580 KB
平均クエリ数 11.00
最終ジャッジ日時 2024-12-20 06:40:07
合計ジャッジ時間 3,551 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 30
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <random>
#include <iomanip>
#include <time.h>
#include <bitset>
#include <map>
#include <numeric>
#include <atcoder/modint>
#include <atcoder/dsu>
using namespace atcoder;
using namespace std;
using mint = modint998244353;
#define ll long long
#define pll pair<ll,ll>

void solve(ll l, ll r, ll lmin, ll rmax, ll remain=10)
{
    if(r-l==1)
    {
        for(int i=0; i<remain; i++)
        {
            cout << "? " << 1 << endl;
            ll tmp;
            cin >> tmp;
        }
        cout << "Yes " << r << " " << r+1 << endl;
        return;
    }
    ll m = (r+l)/2;
    cout << "? " << m+1 << endl;
    ll res = 0;
    cin >> res;
    //[l,m]に最大でres-lmin+1種類存在
    //[m,r)に最大でrmax-res+1種類存在
    if(m-l+1>res-lmin+1) solve(l,m,lmin,res,remain-1);
    else solve(m,r,res,rmax,remain-1);
}

ll n;

int main()
{
    cin >> n;
    solve(0,n,1,n);
}
0