結果

問題 No.850 企業コンテスト2位
ユーザー pockyny
提出日時 2019-07-06 20:49:00
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 42 ms / 2,000 ms
コード長 677 bytes
コンパイル時間 778 ms
コンパイル使用メモリ 72,808 KB
最終ジャッジ日時 2025-01-07 06:24:25
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1
other AC * 27
権限があれば一括ダウンロードができます

ソースコード

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];
}

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

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