結果

問題 No.282 おもりと天秤(2)
ユーザー tubo28tubo28
提出日時 2015-09-18 23:24:06
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 1,550 ms / 5,000 ms
コード長 3,113 bytes
コンパイル時間 1,733 ms
コンパイル使用メモリ 153,880 KB
実行使用メモリ 24,324 KB
平均クエリ数 214.33
最終ジャッジ日時 2023-09-23 21:29:55
合計ジャッジ時間 16,932 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 26 ms
24,024 KB
testcase_01 AC 26 ms
24,312 KB
testcase_02 AC 24 ms
23,424 KB
testcase_03 AC 23 ms
23,820 KB
testcase_04 AC 22 ms
23,436 KB
testcase_05 AC 23 ms
23,976 KB
testcase_06 AC 26 ms
23,976 KB
testcase_07 AC 22 ms
23,472 KB
testcase_08 AC 28 ms
23,604 KB
testcase_09 AC 21 ms
23,436 KB
testcase_10 AC 403 ms
24,036 KB
testcase_11 AC 1,337 ms
24,324 KB
testcase_12 AC 487 ms
23,508 KB
testcase_13 AC 670 ms
23,580 KB
testcase_14 AC 1,194 ms
23,628 KB
testcase_15 AC 1,533 ms
23,520 KB
testcase_16 AC 99 ms
23,604 KB
testcase_17 AC 628 ms
23,460 KB
testcase_18 AC 1,022 ms
24,072 KB
testcase_19 AC 1,079 ms
23,700 KB
testcase_20 AC 1,519 ms
23,568 KB
testcase_21 AC 1,502 ms
23,508 KB
testcase_22 AC 1,550 ms
23,868 KB
testcase_23 AC 21 ms
23,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#define _CRT_SECURE_NO_WARNINGS
// #define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
// #define int ll
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> pii;
#define all(c) begin(c), end(c)
#define range(i,a,b) for(ll i=a; i<ll(b); i++)
#define rep(i,b) range(i,0,b)
#define rangei(i,a,b) for(ll a=a;i<=ll(b);i++)
#define repi(i,b) rangei(i,1,b)
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define mt make_tuple
template<class T> ostream & operator << (ostream &os, vector<T> const &);
template<int n, class...T>
typename enable_if<(n>=sizeof...(T))>::type
_ot(ostream &, tuple<T...> const &){}
template<int n, class...T>
typename enable_if<(n< sizeof...(T))>::type
_ot(ostream &os, tuple<T...> const &t){
    os << (n==0?"":" ") << get<n>(t); _ot<n+1>(os, t);
}
template<class...T>
ostream & operator << (ostream &os, tuple<T...> const &t){
    _ot<0>(os, t); return os;
}
template<class T, class U>
ostream & operator<<(ostream &os, pair<T,U> const &p){
    return os << "(" << p.first << ", " << p.second << ") ";
}
template<class T>
ostream & operator<<(ostream &os, vector<T> const &v){
    rep(i,v.size()) os << v[i] << (i+1==(int)v.size()?"":" "); return os;
}
#ifdef DEBUG
#define dump(...) (cerr << #__VA_ARGS__ << " = " << mt(__VA_ARGS__) \
                   << " [" << __LINE__ << "]" << endl)
#else
#define dump(...)
#endif
void fastios(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    // #define endl '\n'
}
template<class T>
size_t uniq(vector<T> &v){
    sort(v.begin(), v.end());
    v.erase(unique(v.begin(), v.end()), v.end());
    return v.size();
}
template<class T>
size_t uniq(T *l, size_t n){
    sort(l,l+n);
    return unique(l,l+n) - l;
}
#define mems(arr,val) memset(arr,val,sizeof(arr));
int const mod = 1000000007;
int const inf = numeric_limits<int>::max()/8;

int n;

vector<char> ask(vector<pair<int,int>> q){
    int rem = n;
    assert((int)q.size() <= n);
    cout << "?";
    for(auto & p : q){
        rem--;
        cout << " " << p.first << " " << p.second;
    }
    while(rem){
        cout << " 0 0";
        rem--;
    }
    cout << endl;
    vector<char> res(n);
    rep(i,n) cin >> res[i];
    return res;
}

int main(){
    srand(time(0));
    cin >> n;
    vector<int> a(n);
    rep(i,n) a[i] = i+1;
    random_shuffle(a.begin(), a.end());
    vector<pii> q;
    vector<char> r;

    while(1){
        bool finish = true;
        q.clear();
        for(int i=0; i*2+1 < n; i++){
            q.eb(a[i*2], a[i*2+1]);
        }
        r = ask(q);
        for(int i=0; i*2+1 < n; i++){
            if(r[i] == '>'){
                swap(a[i*2], a[i*2+1]);
                finish = false;
            }
        }

        q.clear();
        for(int i=0; i*2+2 < n; i++){
            q.eb(a[i*2+1], a[i*2+2]);
        }
        r = ask(q);
        for(int i=0; i*2+2 < n; i++){
            if(r[i] == '>'){
                swap(a[i*2+1], a[i*2+2]);
                finish = false;
            }
        }
        if(finish) break;
    }
    cout << "! ";
    cout << a << endl;
}
0