結果

問題 No.282 おもりと天秤(2)
ユーザー Lay_ecLay_ec
提出日時 2015-09-18 23:50:33
言語 C++11
(gcc 11.4.0)
結果
TLE  
(最新)
AC  
(最初)
実行時間 -
コード長 1,368 bytes
コンパイル時間 838 ms
コンパイル使用メモリ 89,764 KB
実行使用メモリ 24,360 KB
平均クエリ数 123.88
最終ジャッジ日時 2023-09-23 21:32:53
合計ジャッジ時間 11,733 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 33 ms
24,252 KB
testcase_01 AC 81 ms
23,712 KB
testcase_02 AC 35 ms
24,360 KB
testcase_03 AC 32 ms
23,448 KB
testcase_04 AC 29 ms
23,448 KB
testcase_05 AC 54 ms
23,568 KB
testcase_06 AC 94 ms
23,436 KB
testcase_07 AC 30 ms
23,568 KB
testcase_08 AC 92 ms
23,568 KB
testcase_09 AC 26 ms
23,652 KB
testcase_10 AC 2,959 ms
8,100 KB
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){
			
				if(result[0]==">"){
					ans.push_back(heavy[0]);
					s.erase(heavy[0]);
				}else{
					ans.push_back(heavy[1]);
					s.erase(heavy[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<<"!";
	for(int i=n-1;i>=0;i--) cout<<" "<<ans[i];
	cout<<endl;

}
0