結果

問題 No.282 おもりと天秤(2)
ユーザー Lay_ecLay_ec
提出日時 2015-09-18 23:50:33
言語 C++11
(gcc 13.3.0)
結果
TLE  
(最新)
AC  
(最初)
実行時間 -
コード長 1,368 bytes
コンパイル時間 1,064 ms
コンパイル使用メモリ 95,016 KB
実行使用メモリ 33,456 KB
平均クエリ数 123.88
最終ジャッジ日時 2024-07-16 21:22:34
合計ジャッジ時間 12,016 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 11 TLE * 1
権限があれば一括ダウンロードができます

ソースコード

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