結果

問題 No.282 おもりと天秤(2)
ユーザー btk
提出日時 2015-09-19 00:04:34
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
WA  
実行時間 -
コード長 1,753 bytes
コンパイル時間 896 ms
コンパイル使用メモリ 90,256 KB
実行使用メモリ 25,604 KB
平均クエリ数 601.00
最終ジャッジ日時 2024-07-16 06:01:29
合計ジャッジ時間 28,528 ms
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 2 WA * 22
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<iostream>
#include<fstream>
#include<sstream>
#include<string>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<ctime>
#include<stack>
#include<queue>
#include<set>
#include<map>
#include<vector>
#include<list>
#include<algorithm>
#include<utility>
#include<complex>
#include<functional>
using namespace std;


#define input_init stringstream ss; string strtoken, token; istringstream is
#define input_line  getline(cin, strtoken);is.str(strtoken);is.clear(istringstream::goodbit)
#define input_token(num) ss.str(""); ss.clear(stringstream::goodbit); getline(is, token, ','); ss << token; ss >> num

pair<int, int> cnt[500];
int query[600][500][2];
void sp(int d, int left, int right){
	int num = (right - left);
	int half = num / 2;
	if (half == 0)return;
	for (int i = 0; i < num - half; i++){
		for (int j = left; j < left + half; j++)
			query[d + i][j][0] = j+1;
		for (int j = 0; j < num - half; j++){
			query[d + i][(j + i) % (num - half) + left][1] = left +half+ j+1;
		}
	}
	sp(d + num - half, left, left + half);
	sp(d + num - half, left + half, right);
}
int main(void){
	int N;
	cin >> N;
	for (int i = 0; i <N; i++){
		cnt[i].first = 0; 
		cnt[i].second = i + 1;
		for (int j = 0; j < N; j++)
			query[i][j][0] = query[i][j][1] = 0;
	}
	sp(0,0, N);
	for (int i = 0; i < 600; i++){
		cout << "?";
		for (int j = 0; j < N; j++){
			cout <<" "<< query[i][j][0] << " " << query[i][j][1];
		}
		cout << endl << flush;
		for (int j = 0; j < N; j++){
			string s;
			cin >> s;
			if (s == ">")cnt[query[i][j][0]].first++;
			else if (s == "<")cnt[query[i][j][1]].first++;
		}
	}
	sort(cnt, cnt + N);
	cout << "!";
	for (int i = 0; i < N; i++){
		cout << " " << cnt[i].second;
	}
	cout << endl << flush << endl;
	return(0);
}
0