結果

問題 No.1830 Balanced Majority
ユーザー riano
提出日時 2021-12-25 13:36:40
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 28 ms / 2,000 ms
コード長 835 bytes
コンパイル時間 1,575 ms
コンパイル使用メモリ 166,948 KB
実行使用メモリ 25,580 KB
平均クエリ数 7.54
最終ジャッジ日時 2024-10-08 10:30:44
合計ジャッジ時間 3,740 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1
other AC * 25
権限があれば一括ダウンロードができます

ソースコード

diff #
プレゼンテーションモードにする

#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define riano_ std::ios::sync_with_stdio(false);std::cin.tie(nullptr)
int main() {
riano_;
ll N; cin >> N;
ll l = 1,r = N-1,sl,sr;
cout << "? " << l << endl;
cin >> sl; sl = sl*2-1;
cout << "? " << r << endl;
cin >> sr; sr = sr*2-(N-1);
if(sl==sr){
cout << "! " << l+1 << " " << r << endl;
return 0;
}
int pm = 1;
if(sl>0) pm = -1;
while(l<r){
ll c = (l+r)/2;
cout << "? " << c << endl;
cin >> sl; sl = sl*2-c;
if(sl==0){
l = c; r = c;
}
else if(sl*pm<0){
l = c;
}
else r = c;
}
if(l>=N/2){
cout << "! " << 1 << " " << l << endl;
}
else{
cout << "! " << l+1 << " " << N << endl;
}
}
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
0