結果

問題 No.282 おもりと天秤(2)
ユーザー xuzijian629xuzijian629
提出日時 2018-10-27 19:48:01
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 1,730 ms / 5,000 ms
コード長 2,007 bytes
コンパイル時間 2,181 ms
コンパイル使用メモリ 215,364 KB
実行使用メモリ 24,300 KB
平均クエリ数 220.33
最終ジャッジ日時 2023-09-24 02:00:27
合計ジャッジ時間 18,819 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 27 ms
23,748 KB
testcase_01 AC 29 ms
23,484 KB
testcase_02 AC 23 ms
24,012 KB
testcase_03 AC 22 ms
23,376 KB
testcase_04 AC 22 ms
23,532 KB
testcase_05 AC 24 ms
24,252 KB
testcase_06 AC 25 ms
24,000 KB
testcase_07 AC 21 ms
24,252 KB
testcase_08 AC 25 ms
23,640 KB
testcase_09 AC 21 ms
24,240 KB
testcase_10 AC 419 ms
23,340 KB
testcase_11 AC 1,508 ms
23,796 KB
testcase_12 AC 485 ms
24,240 KB
testcase_13 AC 719 ms
23,328 KB
testcase_14 AC 1,220 ms
23,616 KB
testcase_15 AC 1,603 ms
23,640 KB
testcase_16 AC 107 ms
24,144 KB
testcase_17 AC 674 ms
23,304 KB
testcase_18 AC 1,100 ms
23,604 KB
testcase_19 AC 1,109 ms
23,796 KB
testcase_20 AC 1,632 ms
24,300 KB
testcase_21 AC 1,730 ms
24,240 KB
testcase_22 AC 1,687 ms
23,976 KB
testcase_23 AC 22 ms
24,120 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;
    
    deque<int> ord;
    for (int i = 1; i < n; i++) {
        ord.push_back(i);
    }
    if (n % 2) {
        ord.push_back(-1);
        n++;
    }
    reverse(ord.begin() + (n - 1) / 2, ord.end());
    
    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[n - 1 - j][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