結果

問題 No.282 おもりと天秤(2)
ユーザー xuzijian629xuzijian629
提出日時 2018-10-27 19:20:30
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,944 bytes
コンパイル時間 2,374 ms
コンパイル使用メモリ 213,756 KB
実行使用メモリ 24,492 KB
平均クエリ数 115.38
最終ジャッジ日時 2023-09-23 16:30:16
合計ジャッジ時間 17,858 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 26 ms
24,012 KB
testcase_01 WA -
testcase_02 RE -
testcase_03 RE -
testcase_04 RE -
testcase_05 WA -
testcase_06 WA -
testcase_07 RE -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 RE -
testcase_12 RE -
testcase_13 WA -
testcase_14 RE -
testcase_15 WA -
testcase_16 RE -
testcase_17 RE -
testcase_18 RE -
testcase_19 RE -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 AC 24 ms
24,384 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
using i64 = int64_t;
using vi = vector<i64>;
using vvi = vector<vi>;

int main() {
    int n;
    cin >> n;
    vvi res(n, vi(n));
    int N = n;

    list<int> ord;
    for (int i = 1; i < n / 2 * 2; i++) {
        ord.push_back(i);
    }
    if (n % 2) {
        ord.push_back(-1);
        n++;
    }

    for (int i = 0; i < n - 1; i++) {
        vvi match(n / 2, vi(2));
        match[0][0] = 0;
        int j = 1;
        for (int k: ord) {
            if (j < n / 2) {
                match[j][0] = k;
            } else {
                match[j - n / 2][1] = k;
            }
            j++;
        }
        cout << "?";
        for (int i = 0; i < n / 2; i++) {
            if (match[i][0] == -1 || match[i][1] == -1) {
                cout << " 0 0";
            } else {
                cout << " " << match[i][0] + 1 << " " << match[i][1] + 1;  
            }
        }
        for (int i = 0; i < N - n / 2; i++) {
            cout << " 0 0";
        }
        cout << endl;

        char ch;
        for (int i = 0; i < n / 2; i++) {
            cin >> ch;
            if (match[i][0] == -1 || match[i][1] == -1) {
                assert(ch == '=');
            } else {
                assert(ch != '=');
                if (ch == '>') {
                    res[match[i][0]][match[i][1]] = 1;
                } else {
                    res[match[i][1]][match[i][0]] = 1;
                }
            }
        }
        for (int i = 0; i < N - n / 2; i++) {
            cin >> ch;
        }
        ord.push_back(ord.front());
        ord.pop_front();
    }

    using ii = pair<int, int>;
    vector<ii> cnt;
    for (int i = 0; i < N; i++) {
        cnt.push_back(ii(accumulate(res[i].begin(), res[i].end(), 0), i));
    }
    sort(cnt.begin(), cnt.end());
    cout << "!";
    for (int i = 0; i < N; i++) {
        cout << " " << cnt[i].second + 1;
    }
    cout << endl;
}
0