結果

問題 No.850 企業コンテスト2位
ユーザー beetbeet
提出日時 2019-07-05 22:04:53
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 816 bytes
コンパイル時間 2,634 ms
コンパイル使用メモリ 212,072 KB
実行使用メモリ 24,288 KB
平均クエリ数 236.00
最終ジャッジ日時 2023-09-23 17:27:42
合計ジャッジ時間 5,724 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 30 ms
23,520 KB
testcase_01 AC 24 ms
23,568 KB
testcase_02 AC 23 ms
23,628 KB
testcase_03 AC 25 ms
23,532 KB
testcase_04 AC 25 ms
23,628 KB
testcase_05 AC 26 ms
24,144 KB
testcase_06 AC 23 ms
23,520 KB
testcase_07 AC 28 ms
23,352 KB
testcase_08 AC 30 ms
23,256 KB
testcase_09 AC 30 ms
24,288 KB
testcase_10 AC 35 ms
23,928 KB
testcase_11 AC 35 ms
23,280 KB
testcase_12 AC 35 ms
23,508 KB
testcase_13 AC 35 ms
23,616 KB
testcase_14 AC 34 ms
23,676 KB
testcase_15 AC 34 ms
23,532 KB
testcase_16 AC 34 ms
23,976 KB
testcase_17 AC 35 ms
23,508 KB
testcase_18 AC 33 ms
24,144 KB
testcase_19 AC 33 ms
23,928 KB
testcase_20 WA -
testcase_21 AC 35 ms
24,000 KB
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 AC 25 ms
23,808 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;
  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)];
              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