結果

問題 No.1830 Balanced Majority
ユーザー 沙耶花沙耶花
提出日時 2022-02-04 21:37:14
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 610 bytes
コンパイル時間 4,200 ms
コンパイル使用メモリ 258,840 KB
実行使用メモリ 24,552 KB
平均クエリ数 8.27
最終ジャッジ日時 2023-09-02 04:36:10
合計ジャッジ時間 6,455 ms
ジャッジサーバーID
(参考情報)
judge16 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 AC 25 ms
23,424 KB
testcase_02 AC 25 ms
23,664 KB
testcase_03 AC 25 ms
23,868 KB
testcase_04 WA -
testcase_05 WA -
testcase_06 AC 25 ms
24,396 KB
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 AC 26 ms
23,568 KB
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 AC 25 ms
23,568 KB
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 AC 26 ms
24,060 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <stdio.h>
#include <bits/stdc++.h>
#include <atcoder/all>
using namespace atcoder;
using mint = modint998244353;
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
#define Inf 1000000001

void answer(int n){
	cout<<"! 1 "<<n<<endl;
	exit(0);
}

bool query(int N){
	cout<<"? "<<N<<endl;
	int ret;
	cin>>ret;
	if(ret*2 == N){
		answer(N);
	}
	if(ret*2>N)return true;
	else false;
	return true;
}


int main(){
	int N;
	cin>>N;
	
	bool f = query(2);
	N /= 2;
	int ok = N;
	int ng = 1;
	
	while(ok-ng>1){
		int mid = (ok+ng)/2;
		if(query(mid*2)==f)ng = mid;
		else ok = mid;
	}
	
	
	return 0;
}
0