結果

問題 No.282 おもりと天秤(2)
ユーザー IL_mstaIL_msta
提出日時 2015-09-20 02:34:29
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 945 ms / 5,000 ms
コード長 2,129 bytes
コンパイル時間 862 ms
コンパイル使用メモリ 97,036 KB
実行使用メモリ 24,324 KB
平均クエリ数 265.29
最終ジャッジ日時 2023-09-23 21:44:16
合計ジャッジ時間 12,429 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 27 ms
23,400 KB
testcase_01 AC 29 ms
23,832 KB
testcase_02 AC 25 ms
24,264 KB
testcase_03 AC 26 ms
23,436 KB
testcase_04 AC 27 ms
23,340 KB
testcase_05 AC 29 ms
23,352 KB
testcase_06 AC 32 ms
23,328 KB
testcase_07 AC 26 ms
23,328 KB
testcase_08 AC 32 ms
24,012 KB
testcase_09 AC 25 ms
23,484 KB
testcase_10 AC 552 ms
23,544 KB
testcase_11 AC 808 ms
24,324 KB
testcase_12 AC 582 ms
23,496 KB
testcase_13 AC 814 ms
23,484 KB
testcase_14 AC 645 ms
23,472 KB
testcase_15 AC 873 ms
23,580 KB
testcase_16 AC 138 ms
23,640 KB
testcase_17 AC 840 ms
23,364 KB
testcase_18 AC 557 ms
23,484 KB
testcase_19 AC 573 ms
23,844 KB
testcase_20 AC 931 ms
23,988 KB
testcase_21 AC 931 ms
23,544 KB
testcase_22 AC 945 ms
23,652 KB
testcase_23 AC 25 ms
24,000 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 || q.empty() ){
			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