結果

問題 No.850 企業コンテスト2位
ユーザー pockynypockyny
提出日時 2019-07-06 20:40:18
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
RE  
実行時間 -
コード長 654 bytes
コンパイル時間 602 ms
コンパイル使用メモリ 73,760 KB
実行使用メモリ 24,432 KB
平均クエリ数 194.79
最終ジャッジ日時 2023-09-23 17:46:53
合計ジャッジ時間 12,107 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <iostream>
#include <vector>
using namespace std;
int n,t[610] = {};
vector<int> v[310];
int query(int a, int b){
	if(a==b) return a;
	if(a==0) return b;
	if(b==0) return a;
	cout << "? " << a << " " << b << endl;
	int c; cin >> c;
	v[c].push_back(a^b^c);
	return c;
}

int build(){
	for(int i=n-1;i>0;i--){
		t[i] = query(t[i<<1],t[i<<1|1]);
	}
	return t[1];
}

int max(vector<int> &a){
	if(a.size()==1) return a[0];
	int x = query(a[0],a[1]);
	for(int i=2;i<a.size();i++){
		x = query(x,a[i]);
	}
	return x;
}

int main(){
	int i;
	cin >> n;
	for(i=0;i<n;i++){
		t[i + n] = i + 1;
	}
	int x = build();
	cout << "! " << max(v[x]) << endl;
}
	
	
0