結果

問題 No.850 企業コンテスト2位
ユーザー pockynypockyny
提出日時 2019-07-06 20:47:26
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
TLE  
実行時間 -
コード長 643 bytes
コンパイル時間 750 ms
コンパイル使用メモリ 74,060 KB
実行使用メモリ 38,928 KB
最終ジャッジ日時 2023-09-23 17:47:31
合計ジャッジ時間 7,121 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 TLE -
testcase_01 -- -
testcase_02 -- -
testcase_03 -- -
testcase_04 -- -
testcase_05 -- -
testcase_06 -- -
testcase_07 -- -
testcase_08 -- -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: 関数 ‘int max(std::vector<int>&)’ 内:
main.cpp:29:30: 警告: 制御が非 void 関数の終りに到達しました [-Wreturn-type]
   29 |         cout << "! " << x << endl;
      |                              ^~~~

ソースコード

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