結果

問題 No.282 おもりと天秤(2)
ユーザー Lay_ecLay_ec
提出日時 2015-09-18 23:26:37
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 1,606 bytes
コンパイル時間 978 ms
コンパイル使用メモリ 90,232 KB
実行使用メモリ 24,360 KB
平均クエリ数 73.79
最終ジャッジ日時 2023-09-23 05:59:18
合計ジャッジ時間 11,946 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <iostream>
#include <string>
#include <vector>
#include <cmath>
#include <algorithm>
#include <cstdlib>
#include <ctime>
#include <cstdio>
#include <functional>
#include <set>
#include <sstream>
#include <map>
#include <queue>
#include <stack>
using namespace std;

long long gcd(long long x,long long y){
	return y==0?x:gcd(y,x%y);
}

int main(){

	int n;
	cin>>n;
	
	set<int> s;
	vector<int> ans;
	for(int i=0;i<n;i++){
		s.insert(i+1);
		//cin>>a[i];
	}
	
	while(!s.empty()){

/*		
		cout<<"s=[";
		for(auto it=s.begin();it!=s.end();it++) cout<<(*it)<<" ";
		cout<<"]"<<endl;
*/		
		vector<int> heavy(s.begin(),s.end());

		while(true){
			while(heavy.size()!=2*n) heavy.push_back(0);
			cout<<"?";
			for(int i=0;i<heavy.size();i++) cout<<" "<<heavy[i];
			cout<<endl;
			
			vector<string> result(n);
			int cnt=0;
			for(int i=0;i<n;i++){
				cin>>result[i];
				if(result[i]!="=") cnt++;
			}
			if(cnt==1) break;

			vector<int> next_h;
			for(int i=0;i<n;i++){
				if(result[i]==">") next_h.push_back(heavy[2*i]);
				else if(result[i]=="<") next_h.push_back(heavy[2*i+1]); 
			}
			swap(heavy,next_h);
		}
		
		cout<<"? "<<heavy[0]<<" "<<heavy[1];
		for(int i=0;i<2*n-2;i++) cout<<" "<<0;
		cout<<endl;
		
		string result,dummy;
		cin>>result;
		for(int i=0;i<n-1;i++) cin>>dummy;
			
		if(result==">"){
			ans.push_back(heavy[0]);
			if(heavy[1]!=0) ans.push_back(heavy[1]);
		}else{
			ans.push_back(heavy[1]);
			if(heavy[0]!=0) ans.push_back(heavy[0]);			
		}
		
		s.erase(heavy[0]);
		s.erase(heavy[1]);
		
	}

	cout<<"!";
	for(int i=n-1;i>=0;i--) cout<<" "<<ans[i];
	cout<<endl;

}
0