結果
| 問題 |
No.2753 鳩の巣原理
|
| コンテスト | |
| ユーザー |
ococonomy1
|
| 提出日時 | 2024-05-10 21:47:44 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 2,574 bytes |
| コンパイル時間 | 910 ms |
| コンパイル使用メモリ | 104,608 KB |
| 最終ジャッジ日時 | 2025-02-21 12:33:04 |
|
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | WA * 30 |
ソースコード
//#pragma GCC target("avx2")
//#pragma GCC optimize("O3")
//#pragma GCC optimize("unroll-loops")
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <complex>
#include <climits>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <tuple>
#include <vector>
using namespace std;
using ll = long long;
using pii = pair<int,int>;
using pll = pair<ll,ll>;
using pli = pair<ll,int>;
#define TEST cerr << "TEST" << endl
#define AMARI 998244353
//#define AMARI 1000000007
#define el '\n'
#define El '\n'
void print_question(int i){
cout << "? ";
//flush忘れずに
cout << (i + 1) << endl;
return;
}
#define MULTI_TEST_CASE false
void solve(void){
//問題を見たらまず「この問題設定から言えること」をいっぱい言う
//一個回答に繋がりそうな解法が見えても、実装や細かい詰めに時間がかかりそうなら別の方針を考えてみる
//添え字回りで面倒になりそうなときは楽になる言い換えを実装の前にじっくり考える
//ある程度考察しても全然取っ掛かりが見えないときは実験をしてみる
//よりシンプルな問題に言い換えられたら、言い換えた先の問題を自然言語ではっきりと書く
//各鳩の巣について、鳩がいる数について、広い方の単調増加になっている
//N に住んでいるのは N 未満(鳩の巣原理より必ず被りがある、と言いたそう)
//i について鳩がいくついるかを教えてもらえるから、二分探索してね
//1024 に対し10回なので、結構丁寧に範囲を狭めていかないとヤバいことで知られている
int n;
cin >> n;
int q = 10;
int l = 0,r = n - 2;
//[l,r]の範囲に答えがある
//答えについて、i,i+1の数が同じ、というように持つ
while(q--){
if(l == r){
print_question(0);
continue;
}
int c = (l + r) / 2;
print_question(c);
int temp;
cin >> temp;
if(temp >= c + 1){
l = c;
}
else{
r = c - 1;
}
}
cout << "! " << l + 1 << ' ' << l + 2 << el;
return;
}
void calc(void){
return;
}
signed main(void){
cin.tie(nullptr);
ios::sync_with_stdio(false);
calc();
int t = 1;
if(MULTI_TEST_CASE)cin >> t;
while(t--){
solve();
}
return 0;
}
ococonomy1