結果

問題 No.355 数当てゲーム(2)
ユーザー imulanimulan
提出日時 2016-07-13 03:37:51
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 28 ms / 2,000 ms
コード長 1,739 bytes
コンパイル時間 1,813 ms
コンパイル使用メモリ 170,288 KB
実行使用メモリ 24,348 KB
平均クエリ数 21.48
最終ジャッジ日時 2023-09-24 00:11:10
合計ジャッジ時間 5,142 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 28 ms
24,036 KB
testcase_01 AC 21 ms
23,568 KB
testcase_02 AC 21 ms
23,808 KB
testcase_03 AC 20 ms
23,448 KB
testcase_04 AC 21 ms
23,856 KB
testcase_05 AC 20 ms
24,264 KB
testcase_06 AC 21 ms
24,288 KB
testcase_07 AC 20 ms
24,348 KB
testcase_08 AC 20 ms
23,376 KB
testcase_09 AC 20 ms
23,940 KB
testcase_10 AC 21 ms
23,436 KB
testcase_11 AC 22 ms
23,568 KB
testcase_12 AC 21 ms
24,060 KB
testcase_13 AC 21 ms
23,580 KB
testcase_14 AC 20 ms
23,676 KB
testcase_15 AC 21 ms
23,448 KB
testcase_16 AC 20 ms
24,240 KB
testcase_17 AC 20 ms
23,652 KB
testcase_18 AC 20 ms
23,412 KB
testcase_19 AC 22 ms
23,400 KB
testcase_20 AC 21 ms
23,568 KB
testcase_21 AC 22 ms
23,676 KB
testcase_22 AC 21 ms
23,676 KB
testcase_23 AC 21 ms
23,436 KB
testcase_24 AC 20 ms
23,688 KB
testcase_25 AC 19 ms
23,580 KB
testcase_26 AC 20 ms
23,820 KB
testcase_27 AC 20 ms
23,412 KB
testcase_28 AC 21 ms
23,448 KB
testcase_29 AC 19 ms
24,036 KB
testcase_30 AC 21 ms
23,580 KB
testcase_31 AC 21 ms
23,580 KB
testcase_32 AC 21 ms
24,120 KB
testcase_33 AC 21 ms
23,688 KB
testcase_34 AC 20 ms
23,688 KB
testcase_35 AC 19 ms
24,324 KB
testcase_36 AC 19 ms
23,832 KB
testcase_37 AC 22 ms
24,348 KB
testcase_38 AC 21 ms
23,424 KB
testcase_39 AC 22 ms
24,060 KB
testcase_40 AC 22 ms
23,436 KB
testcase_41 AC 21 ms
23,568 KB
testcase_42 AC 20 ms
23,688 KB
testcase_43 AC 21 ms
23,844 KB
testcase_44 AC 20 ms
24,060 KB
testcase_45 AC 20 ms
24,348 KB
testcase_46 AC 23 ms
23,424 KB
testcase_47 AC 21 ms
23,580 KB
testcase_48 AC 21 ms
23,844 KB
testcase_49 AC 21 ms
23,676 KB
testcase_50 AC 21 ms
23,844 KB
testcase_51 AC 20 ms
23,436 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define each(itr,c) for(__typeof(c.begin()) itr=c.begin(); itr!=c.end(); ++itr)
#define all(x) (x).begin(),(x).end()
#define mp make_pair
#define pb push_back
#define fi first
#define se second

typedef vector<int> vi;

int x,y;

void query(const vi &v)
{
    //クエリ生成
    rep(i,v.size())
    {
        if(i) printf(" ");
        printf("%d", v[i]);
    }
    printf("\n");
    cout << flush;
    //答え取得
    cin >>x >>y;
}


int main()
{
    bool end=false;

    //まず012を固定,3~9を調べる
    vi v1(4);
    rep(i,3) v1[i]=i;

    int s1[10]={0};
    for(int i=3; i<=9; ++i)
    {
        v1[3]=i;
        query(v1);

        if(x==4)
        {
            end=true;
            break;
        }

        s1[i]=x+y;
    }

    if(!end)
    {
        int large=0,small=4;
        for(int i=3; i<=9; ++i)
        {
            large=max(large,s1[i]);
            small=min(small,s1[i]);
        }

        //largeとsmallにグループ分け
        vi L,S;
        for(int i=3; i<=9; ++i)
        {
            if(s1[i]==large) L.pb(i);
            if(s1[i]==small) S.pb(i);
        }

        vi v2(4);
        //Sはハズレ数字の集合,最低でも3個はある
        rep(i,3) v2[i]=S[i];
        //その3つのハズレ数字を固定し,012の可能性を調べる
        rep(i,3)
        {
            v2[3]=i;
            query(v2);

            //答えにiは含まれている
            if(x+y==1) L.pb(i);
        }

        sort(all(L));

        do{
            query(L);
            if(x==4) break;
        }while(next_permutation(all(L)));
    }

    return 0;
}
0