結果

問題 No.850 企業コンテスト2位
ユーザー kotatsugamekotatsugame
提出日時 2020-03-11 22:55:09
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 35 ms / 2,000 ms
コード長 721 bytes
コンパイル時間 645 ms
コンパイル使用メモリ 75,716 KB
実行使用メモリ 24,360 KB
平均クエリ数 200.11
最終ジャッジ日時 2023-09-23 20:46:06
合計ジャッジ時間 3,213 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 27 ms
23,400 KB
testcase_01 AC 23 ms
23,784 KB
testcase_02 AC 22 ms
23,400 KB
testcase_03 AC 23 ms
23,604 KB
testcase_04 AC 22 ms
23,592 KB
testcase_05 AC 23 ms
24,240 KB
testcase_06 AC 23 ms
23,580 KB
testcase_07 AC 26 ms
24,216 KB
testcase_08 AC 28 ms
23,784 KB
testcase_09 AC 29 ms
23,700 KB
testcase_10 AC 32 ms
23,364 KB
testcase_11 AC 34 ms
23,736 KB
testcase_12 AC 31 ms
23,892 KB
testcase_13 AC 32 ms
23,520 KB
testcase_14 AC 31 ms
23,724 KB
testcase_15 AC 32 ms
23,712 KB
testcase_16 AC 31 ms
24,360 KB
testcase_17 AC 31 ms
23,364 KB
testcase_18 AC 32 ms
23,988 KB
testcase_19 AC 33 ms
24,216 KB
testcase_20 AC 33 ms
23,376 KB
testcase_21 AC 33 ms
23,604 KB
testcase_22 AC 35 ms
23,784 KB
testcase_23 AC 32 ms
23,784 KB
testcase_24 AC 32 ms
23,580 KB
testcase_25 AC 33 ms
23,484 KB
testcase_26 AC 35 ms
23,892 KB
testcase_27 AC 22 ms
23,772 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp:7:1: 警告: ISO C++ では型の無い ‘main’ の宣言を禁止しています [-Wreturn-type]
    7 | main()
      | ^~~~

ソースコード

diff #

#include<iostream>
#include<vector>
using namespace std;
vector<pair<int,int> >ask;
int N;
vector<int>now;
main()
{
	cin>>N;
	for(int i=1;i<=N;i++)now.push_back(i);
	while(now.size()>1)
	{
		vector<int>nxt;
		int i=0;
		for(;i+1<now.size();i+=2)
		{
			cout<<"? "<<now[i]<<" "<<now[i+1]<<endl;
			int t;
			cin>>t;
			nxt.push_back(t);
			ask.push_back(make_pair(now[i],now[i+1]));
		}
		if(i<now.size())nxt.push_back(now[i]);
		now=nxt;
	}
	int one=now[0];
	vector<int>ok;
	for(pair<int,int>p:ask)
	{
		if(p.first==one)ok.push_back(p.second);
		else if(p.second==one)ok.push_back(p.first);
	}
	int two=ok[0];
	for(int i=1;i<ok.size();i++)
	{
		cout<<"? "<<two<<" "<<ok[i]<<endl;
		cin>>two;
	}
	cout<<"! "<<two<<endl;
}
0