結果

問題 No.282 おもりと天秤(2)
ユーザー keikei
提出日時 2018-10-04 23:36:55
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 1,701 ms / 5,000 ms
コード長 2,876 bytes
コンパイル時間 1,755 ms
コンパイル使用メモリ 175,568 KB
実行使用メモリ 24,408 KB
平均クエリ数 212.58
最終ジャッジ日時 2023-09-24 01:58:31
合計ジャッジ時間 18,254 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 26 ms
23,940 KB
testcase_01 AC 29 ms
24,324 KB
testcase_02 AC 27 ms
23,304 KB
testcase_03 AC 25 ms
23,352 KB
testcase_04 AC 26 ms
23,868 KB
testcase_05 AC 27 ms
23,556 KB
testcase_06 AC 30 ms
23,556 KB
testcase_07 AC 26 ms
23,568 KB
testcase_08 AC 30 ms
24,408 KB
testcase_09 AC 25 ms
23,940 KB
testcase_10 AC 426 ms
24,396 KB
testcase_11 AC 1,447 ms
24,048 KB
testcase_12 AC 468 ms
23,868 KB
testcase_13 AC 726 ms
23,472 KB
testcase_14 AC 1,221 ms
23,316 KB
testcase_15 AC 1,524 ms
23,304 KB
testcase_16 AC 97 ms
23,304 KB
testcase_17 AC 664 ms
23,676 KB
testcase_18 AC 1,096 ms
23,556 KB
testcase_19 AC 1,136 ms
23,928 KB
testcase_20 AC 1,670 ms
24,060 KB
testcase_21 AC 1,670 ms
24,060 KB
testcase_22 AC 1,701 ms
23,340 KB
testcase_23 AC 25 ms
23,952 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LINF = 1e18;
template<class S,class T> ostream& operator << (ostream& out,const pair<S,T>& o){ out << "(" << o.first << "," << o.second << ")"; return out; }
template<class T> ostream& operator << (ostream& out,const vector<T> V){ for(int i = 0; i < V.size(); i++){ out << V[i]; if(i!=V.size()-1) out << " ";} return out; }
template<class T> ostream& operator << (ostream& out,const vector<vector<T> > Mat){ for(int i = 0; i < Mat.size(); i++) { if(i != 0) out << endl; out << Mat[i];} return out; }
template<class S,class T> ostream& operator << (ostream& out,const map<S,T> mp){ out << "{ "; for(auto it = mp.begin(); it != mp.end(); it++){ out << it->first << ":" << it->second; if(mp.size()-1 != distance(mp.begin(),it)) out << ", "; } out << " }"; return out; }

/*
 <url:https://yukicoder.me/problems/no/282>
 問題文============================================================
 =================================================================
 解説=============================================================
 ================================================================
 */
int main(void) {
    cin.tie(0); ios_base::sync_with_stdio(false);
    ll N; cin >> N;
    vector<ll> omori(N); iota(omori.begin(),omori.end(),1);
    bool update;
    for(int kassa = 0;;kassa++){
        update = false;
        vector<pll> tenbin(N);
        {
            fill(tenbin.begin(),tenbin.end(),make_pair(0, 0));
            for(int i = 0; i < N-1;i+=2) tenbin[i] = {omori[i],omori[i+1]};
            cout << "?";
            for(int i = 0; i < N;i++) cout << " " << tenbin[i].first << " " << tenbin[i].second;
            cout << endl;
            
            vector<char> rep(N); for(auto& in:rep) cin >> in;
            for(int i = 0; i < N;i++){
                if(tenbin[i].first == 0 || tenbin[i].second == 0) continue;
                if(rep[i] == '>'){
                    swap(omori[i],omori[i+1]);
                    update = true;
                }
            }
        }
        {
            fill(tenbin.begin(),tenbin.end(),make_pair(0, 0));
            for(int i = 0; i < N-2;i+=2) tenbin[i] = {omori[i+1],omori[i+2]};
            cout << "?";
            for(int i = 0; i < N;i++) cout << " " << tenbin[i].first << " " << tenbin[i].second;
            cout << endl;
            
            vector<char> rep(N); for(auto& in:rep) cin >> in;
            for(int i = 0; i < N;i++){
                if(tenbin[i].first == 0 || tenbin[i].second == 0) continue;
                if(rep[i] == '>'){
                    swap(omori[i+1],omori[i+2]);
                    update = true;
                }
            }
        }
        if(!update) break;
    }
    cout << "! " << omori << endl;
    return 0;
}
0