結果

問題 No.282 おもりと天秤(2)
ユーザー IL_mstaIL_msta
提出日時 2015-09-20 02:18:52
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 2,116 bytes
コンパイル時間 1,313 ms
コンパイル使用メモリ 96,776 KB
実行使用メモリ 24,492 KB
平均クエリ数 264.38
最終ジャッジ日時 2023-09-23 06:26:30
合計ジャッジ時間 18,304 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 26 ms
23,472 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 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 AC 25 ms
24,036 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#define _USE_MATH_DEFINES
 
#include <iostream>
#include <iomanip>
#include <sstream>
 
#include <algorithm>
#include <cmath>
 
#include <string>
#include <queue>
#include <vector>
#include <complex>
#include <set>
#include <map>
#include <stack>
#include <list>
 
/////////
#define REP(i, x, n) for(int i = x; i < n; i++)
#define rep(i,n) REP(i,0,n)
#define P(p) cout<<(p)<<endl;
 
#define PII pair<int,int>
/////////
typedef long long LL;
typedef long double LD;
/////////
using namespace::std;
/////////
vector<int> hist(500);
int N,n;

void solve(){
	cin >> N;
	queue<PII> q;
	PII temp;
	for(int i=1;i<N;++i){
		for(int j=i+1;j<=N;++j){
			temp.first = i;
			temp.second = j;
			q.push( temp );
		}
	}
	vector<bool> use(N,false);
	vector<PII> IN( N );
	vector<PII>::iterator it,endit;
	int loop = 0;
	int cnt = 0;
	use = vector<bool>(N,false);

	string str;
	while( !q.empty() ){
		temp = q.front();
		q.pop();
		if( !use[temp.first-1] && !use[temp.second-1] ){
			IN[cnt] = temp;
			++cnt;
			use[temp.first-1] = true;
			use[temp.second-1] = true;
		}else{
			q.push( temp );
		}
		++loop;
		if( loop >= (N)*(N-1)/2 || cnt >= N/2 ){
			it = IN.begin();
			endit = IN.end();
			cnt = 0;
			cout << "?";
			for( ;it != endit;++it ){
				cout << " " << it->first << " " << it->second;
				++cnt;
			}
			for(int k= cnt;k<N;++k){
				cout << " 0 0";
			}
			cout << endl;
			for(int i=0;i<cnt;++i){
				cin >> str;
				if( IN[i].first == 0 || IN[i].second == 0)continue;
				if( str == "<" ){
					++hist[ IN[i].second-1 ];
				}else{
					++hist[ IN[i].first-1 ];
				}
			}
			for(int k=cnt;k<N;++k){
				cin >> str;
			}
			/////////////
			loop = 0;
			cnt = 0;
			use = vector<bool>(N,false);
			temp.first = 0;
			temp.second = 0;
			IN = vector<PII>(N,temp);
		}
	}
	
	vector<int> ret(N,0);
	for(int i=0;i<N;++i){
		ret[ hist[i] ] = i;
	}
	cout << "!";
	for(int i=0;i<N;++i){
		cout << " " << ret[i]+1;
	}
	cout << endl;
	return ;
}

int main(void){
    std::cin.tie(0); 
    std::ios::sync_with_stdio(false);
    std::cout << std::fixed;//
    //cout << setprecision(16);//
	
	//cpp
	solve();
	return 0;
}
0