結果

問題 No.850 企業コンテスト2位
ユーザー hnakashimahnakashima
提出日時 2019-07-05 23:04:02
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 1,076 bytes
コンパイル時間 881 ms
コンパイル使用メモリ 87,800 KB
実行使用メモリ 24,384 KB
平均クエリ数 194.79
最終ジャッジ日時 2023-09-23 17:39:13
合計ジャッジ時間 8,444 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 AC 27 ms
23,484 KB
testcase_03 AC 26 ms
24,192 KB
testcase_04 WA -
testcase_05 AC 26 ms
24,180 KB
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
using namespace std;
#define REP(i,m,n) for(int i=(int)m ; i < (int) n ; ++i )
#define rep(i,n) REP(i,0,n)
typedef long long ll;
typedef pair<int,int> pint;
typedef pair<ll,int> pli;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1000003 ;

int main(){
  int n;
  cin >> n;
  queue<int> que;
  for(int i=1;i<=n;i++)que.push(i);
  while(que.size()>=3){
    int x=que.front();
    que.pop();
    int y=que.front();
    que.pop();
    cout << "? " << x << ' ' << y << endl;
    cout << flush;
    int temp;
    cin >> temp;
    que.push(temp);
  }
  int xx=que.front();
  que.pop();
  int yy=que.front();
  que.pop();
  int ans;
  cout << "? " << xx << ' ' << yy << endl;
  cout << flush;
  cin >> ans;
  if(ans==xx){
    cout << "! " << yy << endl;
    cout << flush;
  }
  else{
    cout << "! " << xx << endl;
    cout << flush;
  }
return 0;}
0