結果

問題 No.282 おもりと天秤(2)
ユーザー kurenai3110kurenai3110
提出日時 2017-01-17 16:32:10
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 1,934 ms / 5,000 ms
コード長 1,212 bytes
コンパイル時間 657 ms
コンパイル使用メモリ 76,884 KB
実行使用メモリ 24,456 KB
平均クエリ数 268.12
最終ジャッジ日時 2023-09-24 00:50:33
合計ジャッジ時間 22,525 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 29 ms
23,400 KB
testcase_01 AC 33 ms
23,508 KB
testcase_02 AC 27 ms
24,036 KB
testcase_03 AC 27 ms
24,048 KB
testcase_04 AC 26 ms
23,616 KB
testcase_05 AC 32 ms
23,520 KB
testcase_06 AC 33 ms
23,652 KB
testcase_07 AC 27 ms
24,264 KB
testcase_08 AC 33 ms
24,036 KB
testcase_09 AC 25 ms
23,520 KB
testcase_10 AC 456 ms
24,372 KB
testcase_11 AC 1,734 ms
23,388 KB
testcase_12 AC 902 ms
23,520 KB
testcase_13 AC 1,139 ms
24,360 KB
testcase_14 AC 1,527 ms
24,000 KB
testcase_15 AC 1,934 ms
23,988 KB
testcase_16 AC 124 ms
23,220 KB
testcase_17 AC 1,158 ms
23,364 KB
testcase_18 AC 1,559 ms
23,604 KB
testcase_19 AC 1,446 ms
24,456 KB
testcase_20 AC 1,774 ms
23,664 KB
testcase_21 AC 1,844 ms
23,520 KB
testcase_22 AC 1,829 ms
23,640 KB
testcase_23 AC 25 ms
23,820 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <map>
using namespace std;
typedef long long ll;
#define max2(a,b) a=max(a,b)

bool A[500][500];

int main()
{
	int n; cin >> n;
	vector<vector<int>>from(n);

	bool flag = true;
	while (flag) {
		cout << "?";
		vector<bool>B(n);
		vector<pair<int, int>>P;
		for (int i = 0; i < n; i++) {
			if (B[i])continue;
			for (int j = i + 1; j < n; j++) {
				if (B[j] || A[i][j])continue;
				else {
					cout << " " << i + 1 << " " << j + 1;
					B[i] = B[j] = true;
					A[i][j] = true;
					P.push_back(make_pair(i,j));
					break;
				}
			}
		}
		if (P.size() == 0)flag = false;
		for (int i = P.size(); i < n; i++)cout << " " << 0 << " " << 0;
		cout << endl;

		for (int i = 0; i < P.size(); i++) {
			char c; cin >> c;
			if (c == '<') {
				from[P[i].second].push_back(P[i].first);
			}
			else if (c == '>') {
				from[P[i].first].push_back(P[i].second);
			}
		}
		for (int i = P.size(); i < n; i++) {
			char c; cin >> c;
		}
	}

	vector<int>ans(n);
	for (int i = 0; i < n; i++) {
		ans[from[i].size()] = i + 1;
	}

	cout << "!";
	for (int i = 0; i < n; i++) {
		cout << " " << ans[i];
	}
	cout << endl;

    return 0;
}

0