結果

問題 No.355 数当てゲーム(2)
ユーザー face4face4
提出日時 2018-08-28 22:23:57
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 24 ms / 2,000 ms
コード長 979 bytes
コンパイル時間 520 ms
コンパイル使用メモリ 70,444 KB
実行使用メモリ 24,384 KB
平均クエリ数 22.29
最終ジャッジ日時 2023-09-24 01:53:30
合計ジャッジ時間 4,211 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 24 ms
23,364 KB
testcase_01 AC 21 ms
23,376 KB
testcase_02 AC 20 ms
23,532 KB
testcase_03 AC 23 ms
24,060 KB
testcase_04 AC 21 ms
23,556 KB
testcase_05 AC 20 ms
24,312 KB
testcase_06 AC 21 ms
24,384 KB
testcase_07 AC 20 ms
23,520 KB
testcase_08 AC 20 ms
23,436 KB
testcase_09 AC 23 ms
23,448 KB
testcase_10 AC 22 ms
24,048 KB
testcase_11 AC 20 ms
23,820 KB
testcase_12 AC 20 ms
23,664 KB
testcase_13 AC 21 ms
23,664 KB
testcase_14 AC 20 ms
23,532 KB
testcase_15 AC 22 ms
24,036 KB
testcase_16 AC 22 ms
23,652 KB
testcase_17 AC 20 ms
23,556 KB
testcase_18 AC 21 ms
23,400 KB
testcase_19 AC 21 ms
23,424 KB
testcase_20 AC 20 ms
23,388 KB
testcase_21 AC 21 ms
23,364 KB
testcase_22 AC 21 ms
24,312 KB
testcase_23 AC 22 ms
24,372 KB
testcase_24 AC 21 ms
23,400 KB
testcase_25 AC 21 ms
24,036 KB
testcase_26 AC 20 ms
23,556 KB
testcase_27 AC 19 ms
24,276 KB
testcase_28 AC 20 ms
23,652 KB
testcase_29 AC 20 ms
23,808 KB
testcase_30 AC 22 ms
24,072 KB
testcase_31 AC 21 ms
24,060 KB
testcase_32 AC 22 ms
23,400 KB
testcase_33 AC 20 ms
24,348 KB
testcase_34 AC 21 ms
24,072 KB
testcase_35 AC 19 ms
24,312 KB
testcase_36 AC 21 ms
23,436 KB
testcase_37 AC 24 ms
23,400 KB
testcase_38 AC 21 ms
23,532 KB
testcase_39 AC 22 ms
24,312 KB
testcase_40 AC 21 ms
23,664 KB
testcase_41 AC 20 ms
24,072 KB
testcase_42 AC 20 ms
23,400 KB
testcase_43 AC 20 ms
23,964 KB
testcase_44 AC 20 ms
23,640 KB
testcase_45 AC 20 ms
24,036 KB
testcase_46 AC 21 ms
24,048 KB
testcase_47 AC 20 ms
23,436 KB
testcase_48 AC 21 ms
24,036 KB
testcase_49 AC 21 ms
23,688 KB
testcase_50 AC 21 ms
23,388 KB
testcase_51 AC 20 ms
23,532 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<iostream>
#include<algorithm>
using namespace std;

int hit = 0, blow = 0;

int getNext(int arr[4], int pos){
    int next = (arr[pos] + 1)%10;
    while(1){
        bool judge = true;
        for(int i = 0; i < 4; i++)  if(arr[i] == next)  judge = false;
        if(judge)   break;
        else        next = (next+1)%10;
    }
    return next;
}

void ask(int arr[4]){
    cout << arr[0] << " " << arr[1] << " " << arr[2] << " " << arr[3] << endl << flush;
    cin >> hit >> blow;
    if(hit == 4)    exit(0);
}

int main(){
    int arr[4];
    arr[0] = 0, arr[1] = 1, arr[2] = 2, arr[3] = 3;

    ask(arr);
    int before = hit + blow;

    int now = 0;

    while(before < 4){
        int tmp = arr[now];
        arr[now] = getNext(arr, now);
        ask(arr);
        if(hit + blow > before){
            now++;
        }
        before = hit + blow;
    }

    sort(arr, arr+4);

    do{
        ask(arr);
    }while(next_permutation(arr, arr+4));

    return 0;
}
0