結果

問題 No.850 企業コンテスト2位
ユーザー beetbeet
提出日時 2019-07-05 22:06:09
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
RE  
実行時間 -
コード長 882 bytes
コンパイル時間 2,299 ms
コンパイル使用メモリ 209,580 KB
実行使用メモリ 24,312 KB
平均クエリ数 207.86
最終ジャッジ日時 2023-09-23 17:27:50
合計ジャッジ時間 6,803 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 28 ms
24,312 KB
testcase_01 AC 26 ms
23,880 KB
testcase_02 AC 25 ms
23,664 KB
testcase_03 AC 25 ms
24,156 KB
testcase_04 AC 26 ms
23,532 KB
testcase_05 AC 26 ms
23,544 KB
testcase_06 AC 25 ms
24,156 KB
testcase_07 AC 30 ms
23,820 KB
testcase_08 AC 33 ms
23,412 KB
testcase_09 AC 32 ms
23,820 KB
testcase_10 AC 36 ms
23,268 KB
testcase_11 AC 36 ms
23,640 KB
testcase_12 AC 35 ms
23,388 KB
testcase_13 AC 35 ms
23,508 KB
testcase_14 AC 35 ms
24,168 KB
testcase_15 AC 35 ms
23,640 KB
testcase_16 AC 35 ms
24,132 KB
testcase_17 AC 35 ms
23,688 KB
testcase_18 AC 34 ms
23,292 KB
testcase_19 AC 36 ms
23,556 KB
testcase_20 RE -
testcase_21 AC 35 ms
23,808 KB
testcase_22 RE -
testcase_23 RE -
testcase_24 RE -
testcase_25 RE -
testcase_26 RE -
testcase_27 AC 25 ms
23,676 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;
using Int = long long;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}

//INSERT ABOVE HERE
signed main(){
  int n;
  cin>>n;
  using P = pair<int, int>;
  map<P, int> memo;
  int cnt=0;
  auto comp=[&](int x,int y)->bool{
              if(x==y) return false;
              if(memo.count(P(x,y))) return memo[P(x,y)];
              if(memo.count(P(y,x))) return !memo[P(y,x)];
              cnt++;
              assert(cnt<=334);
              cout<<"? "<<x<<" "<<y<<endl;
              int ans;
              cin>>ans;
              return (memo[P(x,y)]=(ans==x));
            };
  vector<int> vs(n);
  iota(vs.begin(),vs.end(),1);
  partial_sort(vs.begin(),vs.begin()+2,vs.end(),comp);
  cout<<"! "<<vs[1]<<endl;
  return 0;
}
0