結果

問題 No.355 数当てゲーム(2)
ユーザー tottoripapertottoripaper
提出日時 2018-03-11 14:47:17
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 2,162 bytes
コンパイル時間 1,790 ms
コンパイル使用メモリ 174,440 KB
実行使用メモリ 24,444 KB
平均クエリ数 50.42
最終ジャッジ日時 2023-09-23 15:57:00
合計ジャッジ時間 7,663 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 AC 26 ms
23,796 KB
testcase_02 AC 26 ms
24,300 KB
testcase_03 AC 27 ms
24,288 KB
testcase_04 AC 27 ms
23,340 KB
testcase_05 AC 26 ms
23,328 KB
testcase_06 AC 26 ms
24,216 KB
testcase_07 WA -
testcase_08 AC 26 ms
24,264 KB
testcase_09 WA -
testcase_10 AC 25 ms
23,664 KB
testcase_11 AC 26 ms
23,376 KB
testcase_12 AC 27 ms
23,664 KB
testcase_13 AC 26 ms
24,000 KB
testcase_14 WA -
testcase_15 AC 26 ms
23,364 KB
testcase_16 AC 26 ms
24,060 KB
testcase_17 AC 26 ms
23,376 KB
testcase_18 WA -
testcase_19 AC 25 ms
24,060 KB
testcase_20 AC 27 ms
23,652 KB
testcase_21 WA -
testcase_22 AC 25 ms
23,472 KB
testcase_23 AC 26 ms
23,952 KB
testcase_24 AC 26 ms
24,228 KB
testcase_25 AC 27 ms
23,364 KB
testcase_26 AC 25 ms
23,328 KB
testcase_27 AC 26 ms
23,328 KB
testcase_28 AC 26 ms
24,288 KB
testcase_29 AC 26 ms
23,484 KB
testcase_30 AC 26 ms
23,808 KB
testcase_31 AC 27 ms
23,580 KB
testcase_32 WA -
testcase_33 AC 26 ms
23,172 KB
testcase_34 AC 26 ms
23,352 KB
testcase_35 RE -
testcase_36 AC 25 ms
24,228 KB
testcase_37 AC 25 ms
23,616 KB
testcase_38 AC 24 ms
24,252 KB
testcase_39 AC 24 ms
23,652 KB
testcase_40 AC 25 ms
23,376 KB
testcase_41 AC 26 ms
23,340 KB
testcase_42 AC 26 ms
23,940 KB
testcase_43 AC 26 ms
24,012 KB
testcase_44 AC 26 ms
24,060 KB
testcase_45 AC 26 ms
23,520 KB
testcase_46 WA -
testcase_47 AC 27 ms
23,784 KB
testcase_48 AC 26 ms
23,556 KB
testcase_49 AC 26 ms
23,364 KB
testcase_50 AC 25 ms
24,288 KB
testcase_51 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>

using namespace std;

#define fst(t) std::get<0>(t)
#define snd(t) std::get<1>(t)
#define thd(t) std::get<2>(t)
#define unless(p) if(!(p))
#define until(p) while(!(p))

using ll = long long;
using P = std::tuple<int,int>;
using P4 = std::tuple<int,int,int,int>;

const int dx[8] = {-1, 1, 0, 0, -1, -1, 1, 1}, dy[8] = {0, 0, -1, 1, -1, 1, -1, 1};

P ask(int x1, int x2, int x3, int x4){
    std::cout << x1 << " " << x2 << " " << x3 << " " << x4 << std::endl;

    int a, b;
    std::cin >> a >> b;

    return std::make_tuple(a, b);
}

P4 f(int a){
    int xs[4];
    iota(xs, xs+4, a);

    int s, t;
    tie(s, t) = ask(xs[0], xs[1], xs[2], xs[3]);

    if(s == 4){
        exit(4);
    }
    
    int n = s + t;

    int res[4];
    fill(res, res+4, -2);
    
    while(true){
        int s;
        tie(s, ignore) = ask(xs[0], xs[1], xs[2], xs[3]);

        if(s == 4){
            exit(0);
        }else if(s == n){
            if(res[0] == -2){
                copy(xs, xs+4, res);
            }else{
                for(int i=0;i<4;++i){
                    res[i] = xs[i] == res[i] ? res[i] : -1;
                }
            }
        }
        
        if(!next_permutation(xs, xs+4)){
            break;
        }
    }

    return std::make_tuple(res[0], res[1], res[2], res[3]);
}

int main(){
    std::cin.tie(nullptr);
    std::ios::sync_with_stdio(false);

    int as[4], bs[4];
    tie(as[0], as[1], as[2], as[3]) = f(0);
    tie(bs[0], bs[1], bs[2], bs[3]) = f(4);

    for(int i=0;i<4;++i){
        as[i] = as[i] != -1 ? as[i] : bs[i];
        bs[i] = as[i];
    }

    {
        int nxt = 8;
        for(int i=0;i<4;++i){
            if(bs[i] == -1){
                bs[i] = nxt;
                ++nxt;
            }
        }

        int s;
        tie(s, ignore) = ask(bs[0], bs[1], bs[2], bs[3]);

        if(s == 4){
            return 0;
        }
    }

    {
        copy(as, as+4, bs);
        
        int nxt = 9;
        for(int i=0;i<4;++i){
            if(bs[i] == -1){
                bs[i] = nxt;
                --nxt;
            }
        }

        ask(bs[0], bs[1], bs[2], bs[3]);
    }    
}
0