結果

問題 No.282 おもりと天秤(2)
ユーザー ShibuyapShibuyap
提出日時 2020-07-04 17:29:54
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 3,397 ms / 5,000 ms
コード長 2,088 bytes
コンパイル時間 2,075 ms
コンパイル使用メモリ 207,116 KB
実行使用メモリ 24,408 KB
平均クエリ数 917.71
最終ジャッジ日時 2023-09-24 02:41:45
合計ジャッジ時間 39,201 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 27 ms
24,408 KB
testcase_01 AC 338 ms
23,712 KB
testcase_02 AC 213 ms
23,916 KB
testcase_03 AC 181 ms
23,520 KB
testcase_04 AC 148 ms
23,520 KB
testcase_05 AC 279 ms
23,472 KB
testcase_06 AC 340 ms
23,700 KB
testcase_07 AC 149 ms
23,508 KB
testcase_08 AC 339 ms
23,652 KB
testcase_09 AC 67 ms
23,664 KB
testcase_10 AC 1,660 ms
23,412 KB
testcase_11 AC 3,089 ms
24,096 KB
testcase_12 AC 1,770 ms
24,408 KB
testcase_13 AC 2,244 ms
23,604 KB
testcase_14 AC 2,879 ms
23,652 KB
testcase_15 AC 3,223 ms
23,484 KB
testcase_16 AC 823 ms
23,892 KB
testcase_17 AC 2,124 ms
24,324 KB
testcase_18 AC 2,649 ms
23,724 KB
testcase_19 AC 2,717 ms
23,472 KB
testcase_20 AC 3,397 ms
24,312 KB
testcase_21 AC 3,261 ms
23,364 KB
testcase_22 AC 3,217 ms
23,412 KB
testcase_23 AC 23 ms
23,448 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
#define yn {puts("Yes");}else{puts("No");}
#define MAX_N 200005

int main() {
    int n;
    cin >> n;
    if(n == 1){
        cout << "! 1" << endl;
        return 0;
    }
    if(n == 2){
        cout << "? 1 2 0 0" << endl;
        fflush(stdout);
        char c;
        cin >> c;
        if(c == '>'){
            cin >> c;
            cout << "! 2 1" << endl;
        }else{
            cin >> c;
            cout << "! 1 2" << endl;
        }
        return 0;
    }
    int nn = n;
    int odd = 0;
    if(n % 2 == 1){
        odd = 1;
        n++;
    }
    int f[n+1][n+1];
    rep(i,n+1){
        rep(j,n+1){
            f[i][j] = 0;
        }
    }
    int a[1000] = {}, b[1000] = {};
    rep(i,n/2){
        a[i] = i+1;
        b[i] = n-i;
    }
    rep(_,1000){
        int x[2000] = {};
        rep(i,n/2){
            x[i*2] = a[i];
            x[i*2+1] = b[i];
            if(x[i*2] == n && odd == 1) x[i*2] = 0;
            if(x[i*2+1] == n && odd == 1) x[i*2+1] = 0;
        }
        cout << '?';
        rep(i,nn*2)cout << ' ' << x[i];
        cout << endl;
        fflush(stdout);
        rep(i,nn){
            char c;
            cin >> c;
            if(c == '<'){
                f[x[i*2]][x[i*2+1]] = 1;
            }
            if(c == '>'){
                f[x[i*2+1]][x[i*2]] = 1;
            }
        }
        int keep = a[n/2-1];
        drep(i,n/2){
            if(i == 0)break;
            a[i] = a[i-1];
        }
        a[1] = b[0];
        rep(i,n/2){
            b[i] = b[i+1];
        }
        b[n/2-1] = keep;
    }

    vector<P> v;
    srep(i,1,nn+1){
        int cnt = 0;
        srep(j,1,nn+1)cnt += f[i][j];
        v.push_back(P(-cnt,i));
    }

    sort(v.begin(), v.end());

    cout << '!';
    rep(i,v.size()){
        cout << ' ' << v[i].second;
    }
    cout << endl;

    return 0;
}
 
 
0