結果

問題 No.282 おもりと天秤(2)
ユーザー Kmcode1Kmcode1
提出日時 2015-09-18 23:00:28
言語 C++11
(gcc 11.4.0)
結果
TLE  
(最新)
AC  
(最初)
実行時間 -
コード長 1,853 bytes
コンパイル時間 1,355 ms
コンパイル使用メモリ 112,840 KB
実行使用メモリ 35,524 KB
最終ジャッジ日時 2023-09-23 21:29:33
合計ジャッジ時間 14,210 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 TLE -
testcase_01 -- -
testcase_02 -- -
testcase_03 -- -
testcase_04 -- -
testcase_05 -- -
testcase_06 -- -
testcase_07 -- -
testcase_08 -- -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
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<cstdio>
#include<cstring>
#include<string>
#include<cctype>
#include<cstdlib>
#include<algorithm>
#include<bitset>
#include<vector>
#include<list>
#include<deque>
#include<queue>
#include<map>
#include<set>
#include<stack>
#include<cmath>
#include<sstream>
#include<fstream>
#include<iomanip>
#include<ctime>
#include<complex>
#include<functional>
#include<climits>
#include<cassert>
#include<iterator>
#include<unordered_map>
#include<unordered_set>
//#include<quadmath.h>
using namespace std;
vector<int> v;
int n;
#define MAX 502
bool cm[MAX][MAX];
set<int> s[MAX];
void output(vector<pair<int,int> > v){
	printf("?");
	for (int i = 0; i < v.size(); i++){
		printf(" %d %d", v[i].first, v[i].second);
	}
	puts("");
	fflush(stdout);
	fflush(stdin);
	char ss[3];
	for (int i = 0; i < v.size(); i++){
		scanf("%s", ss);
		if (ss[0] == '<'){
			cm[v[i].first][v[i].second] = true;
		}
		s[v[i].first].erase(v[i].second);
		s[v[i].second].erase(v[i].first);
	}
	fflush(stdin);
	fflush(stdout);
}
bool cmp(int a, int b){
	return cm[a][b];
}
int main(){
	scanf("%d", &n);
	for (int i = 1; i <= n; i++){
		v.push_back(i);
	}
	int summ = 0;
	for (int i = 1; i <= n; i++){
		for (int j = 1; j <= n; j++){
			if (i == j){
				continue;
			}
			s[i].insert(j);
			summ++;
		}
	}
	int countt = 0;
	while (countt < summ){
		set<int> used;
		used.clear();
		vector<pair<int, int> > v;
		for (int i = 1; i <= n; i++){
			set<int>::iterator ite;
			for (ite = s[i].begin(); ite != s[i].end(); ite++){
				if (used.count(*ite)){

				}
				else{
					v.push_back(make_pair(i,(*ite)));
					used.insert(i);
					used.insert((*ite));
					break;
				}
			}
		}
		output(v);
	}
	sort(v.begin(), v.end(), cmp);
	printf("!");
	for (int i = 0; i < v.size(); i++){
		printf(" %d", v[i]);
	}
	puts("");
	fflush(stdout);
	fflush(stdin);
	return 0;
}
0