結果
| 問題 |
No.1830 Balanced Majority
|
| コンテスト | |
| ユーザー |
SSRS
|
| 提出日時 | 2022-02-04 21:27:05 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 773 bytes |
| コンパイル時間 | 2,360 ms |
| コンパイル使用メモリ | 193,648 KB |
| 最終ジャッジ日時 | 2025-01-27 18:39:17 |
|
ジャッジサーバーID (参考情報) |
judge5 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 |
| other | AC * 2 WA * 23 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
int main(){
int N;
cin >> N;
cout << "? " << 1 << endl;
int S1;
cin >> S1;
cout << "? " << N - 1 << endl;
int S2;
cin >> S2;
if (S1 == S2){
cout << "! " << 2 << ' ' << N - 1 << endl;
} else {
int tv = 1, fv = N - 1;
int p = -1;
while (fv - tv > 1){
int mid = (tv + fv) / 2;
cout << "? " << mid << endl;
int S;
cin >> S;
if (S == 0){
p = mid;
break;
} else if (S1 > 0 && S > 0 || S1 < 0 && S < 0){
tv = mid;
} else {
fv = mid;
}
}
if (p == -1){
p = tv;
}
if (p >= N / 2){
cout << "! " << 1 << ' ' << p << endl;
} else {
cout << "! " << p + 1 << ' ' << N << endl;
}
}
}
SSRS