結果

問題 No.282 おもりと天秤(2)
ユーザー satashunsatashun
提出日時 2015-09-18 23:37:37
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 1,726 ms / 5,000 ms
コード長 1,700 bytes
コンパイル時間 1,749 ms
コンパイル使用メモリ 149,516 KB
実行使用メモリ 24,108 KB
平均クエリ数 220.33
最終ジャッジ日時 2023-09-23 21:32:41
合計ジャッジ時間 18,262 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 29 ms
23,568 KB
testcase_01 AC 28 ms
23,868 KB
testcase_02 AC 24 ms
23,568 KB
testcase_03 AC 23 ms
23,868 KB
testcase_04 AC 24 ms
23,448 KB
testcase_05 AC 27 ms
23,412 KB
testcase_06 AC 30 ms
23,448 KB
testcase_07 AC 24 ms
23,676 KB
testcase_08 AC 29 ms
24,024 KB
testcase_09 AC 24 ms
23,424 KB
testcase_10 AC 455 ms
24,084 KB
testcase_11 AC 1,513 ms
24,072 KB
testcase_12 AC 495 ms
24,000 KB
testcase_13 AC 757 ms
24,072 KB
testcase_14 AC 1,282 ms
24,108 KB
testcase_15 AC 1,616 ms
23,700 KB
testcase_16 AC 108 ms
23,568 KB
testcase_17 AC 722 ms
23,412 KB
testcase_18 AC 1,121 ms
23,688 KB
testcase_19 AC 1,160 ms
23,412 KB
testcase_20 AC 1,698 ms
23,448 KB
testcase_21 AC 1,721 ms
24,060 KB
testcase_22 AC 1,726 ms
23,676 KB
testcase_23 AC 23 ms
23,580 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

typedef pair<int, int> pii;
typedef long long ll;
typedef vector<int> vi;

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
#define rep(i,n) rep2(i,0,n)
#define rep2(i,m,n) for(int i=m;i<(n);i++)
#define ALL(c) (c).begin(),(c).end()

vector<int> g[510];
bool vis[510];
int tbl[510][510];
vi ask[510];
int n;

void gen(int N)
{
    rep(i, N-1) {
	int j = 0, cur = i;
	while (j < i) {
	    tbl[i+1][j+1] = cur;
	    ++cur;
	    if (cur >= N) cur = 1;
	    ++j;
	}
    }
    tbl[N][1] = N-1;
    int cur = 2;
    int i = 2;
    for (; cur < N; ++i, cur += 2) {
	tbl[N][i] = cur;
    }
    cur = 1;
    for (; cur < N-1; cur += 2, ++i) {
	tbl[N][i] = cur;
    }

    rep(i, N) rep(j, i) tbl[j+1][i+1] = tbl[i+1][j+1];

    for (int i = 1; i <= N; ++i) {
	for (int j = 1; j < i; ++j) {
	    if (i <= n) {
		ask[tbl[i][j]].pb(i);
		ask[tbl[i][j]].pb(j);
	    }
	}
    }
}

vi vs;

void dfs(int v) 
{
    vis[v] = 1;
    for (int to : g[v]) if (!vis[to]) dfs(to);
    vs.pb(v);
}

int main() {
    cin >> n;
    int N = n;
    N += N & 1;

    gen(N);

    for (int i = 1; i < N; ++i) {
	while (ask[i].size() < n * 2) ask[i].pb(0);
	cout << "?";
	rep(j, n) {
	    cout << " " << ask[i][j*2] << " " << ask[i][j*2+1];
	}
	cout << endl << flush;

	rep(j, n) {
	    int l = ask[i][j*2], r = ask[i][j*2+1];
	    string s;
	    cin >> s;

	    if (r) {
		if (s[0] == '>') {
		    g[l].pb(r);
		} else if (s[0] == '<') {
		    g[r].pb(l);
		}
	    }
	}
    }

    rep(i, n) if (!vis[i+1]) {
	dfs(i+1);
    }

    cout << "!";
    rep(i, n) cout << " " << vs[i];
    cout << endl;
    cout << flush;

    return 0;
}
0