結果

問題 No.282 おもりと天秤(2)
コンテスト
ユーザー firiexp
提出日時 2019-12-06 10:01:52
言語 C++17(gcc12)
(gcc 12.4.0 + boost 1.89.0)
コンパイル:
g++-12 -O2 -lm -std=c++17 -Wuninitialized -DONLINE_JUDGE -o a.out _filename_
実行:
./a.out
結果
AC  
実行時間 1,932 ms / 5,000 ms
コード長 1,764 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 691 ms
コンパイル使用メモリ 113,224 KB
実行使用メモリ 28,976 KB
平均クエリ数 440.58
最終ジャッジ日時 2026-03-08 21:18:02
合計ジャッジ時間 14,199 ms
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 24
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

#include <iostream>
#include <algorithm>
#include <iomanip>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <bitset>
#include <cmath>

static const int MOD = 1000000007;
using ll = long long;
using namespace std;

template<class T> constexpr T INF = ::numeric_limits<T>::max()/32*15+208;


template <class T>
ostream& operator<<(ostream& os, vector<T> v) {
    os << "{";
    for (int i = 0; i < v.size(); ++i) {
        if(i) os << ", ";
        os << v[i];
    }
    return os << "}";
}

template <class L, class R>
ostream& operator<<(ostream& os, pair<L, R> p) {
    return os << "{" << p.first << ", " << p.second << "}";
}


int main() {
    int n;
    cin >> n;
    if(n == 1){
        cout << "! 1" << endl;
        return 0;
    }
    vector<int> v(n);
    iota(v.begin(),v.end(), 1);
    for (int i = 0; i < 2*n; ++i) {
        cout << "?";
        int cnt = 2*n, cntt = 0;
        if(i&1) {
            for (int j = 0; j < n/2*2; ++j) {
                cout << " " << v[j];
                cnt--; cntt++;
            }
        }else {
            for (int j = 0; j < (n-1)/2*2; ++j) {
                cout << " " << v[(j+1)%n];
                cnt--; cntt++;
            }
        }
        for (int j = 0; j < cnt; ++j) {
            cout << " 0";
        }
        cout << endl;
        for (int j = 0; j < n; ++j) {
            char c;
            cin >> c;
            if(j < cntt && c == '>'){
                if(i&1){
                    swap(v[j*2], v[j*2+1]);
                }else {
                    swap(v[j*2+1], v[(j*2+2)%n]);
                }
            }
        }
    }
    cout << "!";
    for (int i = 0; i < n; ++i) {
        cout << " " << v[i];
    }
    cout << endl;
    return 0;
}
0