結果

問題 No.2753 鳩の巣原理
ユーザー ttkkggww
提出日時 2024-05-14 14:04:05
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 514 bytes
コンパイル時間 4,251 ms
コンパイル使用メモリ 250,392 KB
最終ジャッジ日時 2025-02-21 14:02:21
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 11 WA * 19
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
#include <iostream>
using namespace std;
#include<atcoder/all>
using namespace atcoder;
using ll = long long;
int N;

void solve(){
	ll ok = 1,ng = N;
	for(int _ = 0;_<10;_++){
		ll mid = (ok+ng)/2;
		ll in;
		cout<< "? " << mid << endl;
		cout<< flush;
		cin >> in;
		if(in == mid) {
			ok = max(ng-1,mid);
		}
		else{
			ng = min(ok+1,mid);
		}
	}
	cout<<"Yes "<<ok <<' '<<ng<<endl;
	cout<< flush;
}

signed main(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	cin >> N;
	solve();
}
0