結果

問題 No.355 数当てゲーム(2)
ユーザー なおなお
提出日時 2015-07-25 23:04:01
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 27 ms / 2,000 ms
コード長 1,311 bytes
コンパイル時間 1,332 ms
コンパイル使用メモリ 145,292 KB
実行使用メモリ 24,336 KB
平均クエリ数 5.52
最終ジャッジ日時 2023-09-23 21:02:56
合計ジャッジ時間 5,058 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 27 ms
24,048 KB
testcase_01 AC 23 ms
23,868 KB
testcase_02 AC 23 ms
24,072 KB
testcase_03 AC 23 ms
24,108 KB
testcase_04 AC 23 ms
23,688 KB
testcase_05 AC 24 ms
23,856 KB
testcase_06 AC 23 ms
24,048 KB
testcase_07 AC 25 ms
24,336 KB
testcase_08 AC 24 ms
24,036 KB
testcase_09 AC 24 ms
23,448 KB
testcase_10 AC 23 ms
23,604 KB
testcase_11 AC 24 ms
23,436 KB
testcase_12 AC 25 ms
24,264 KB
testcase_13 AC 25 ms
23,568 KB
testcase_14 AC 25 ms
23,856 KB
testcase_15 AC 24 ms
24,324 KB
testcase_16 AC 24 ms
23,844 KB
testcase_17 AC 24 ms
24,216 KB
testcase_18 AC 23 ms
24,288 KB
testcase_19 AC 24 ms
23,868 KB
testcase_20 AC 23 ms
23,424 KB
testcase_21 AC 24 ms
24,036 KB
testcase_22 AC 24 ms
23,724 KB
testcase_23 AC 23 ms
23,448 KB
testcase_24 AC 24 ms
24,036 KB
testcase_25 AC 24 ms
23,436 KB
testcase_26 AC 24 ms
23,436 KB
testcase_27 AC 23 ms
23,568 KB
testcase_28 AC 23 ms
24,312 KB
testcase_29 AC 24 ms
23,556 KB
testcase_30 AC 23 ms
23,448 KB
testcase_31 AC 23 ms
24,048 KB
testcase_32 AC 23 ms
23,664 KB
testcase_33 AC 23 ms
24,132 KB
testcase_34 AC 25 ms
24,252 KB
testcase_35 AC 23 ms
24,048 KB
testcase_36 AC 24 ms
24,072 KB
testcase_37 AC 24 ms
24,300 KB
testcase_38 AC 24 ms
23,460 KB
testcase_39 AC 24 ms
23,880 KB
testcase_40 AC 24 ms
24,072 KB
testcase_41 AC 24 ms
24,324 KB
testcase_42 AC 24 ms
23,700 KB
testcase_43 AC 22 ms
23,868 KB
testcase_44 AC 24 ms
24,120 KB
testcase_45 AC 25 ms
23,856 KB
testcase_46 AC 25 ms
24,096 KB
testcase_47 AC 25 ms
23,616 KB
testcase_48 AC 23 ms
23,604 KB
testcase_49 AC 23 ms
23,640 KB
testcase_50 AC 24 ms
24,096 KB
testcase_51 AC 23 ms
23,724 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long ull;
#define REP(i, n)           for(int(i)=0;(i)<(n);++(i))

bool m[10000];

int main(){
    REP(i,10000){
        int k = i;
        bool f[10], ff;
        REP(j,10) f[j] = false;
        ff = true;
        REP(j,4){
            int l = k % 10;
            if(f[l]){ ff = false; break; }
            f[l] = true;
            k /= 10;
        }
        if(ff) m[i] = true;
    }

    while(1) REP(i,10000){
        if(!m[i]) continue;

        int N[4], t = i; bool f[10];
        REP(j,10) f[j] = false;
        REP(j,4){ int l = t % 10; N[3-j] = l, f[l] = true, t /= 10; }
        REP(j,4) cout << N[j] << " ";
        cout << endl;

        int x = -1, y = -1;
        cin >> x >> y;
        //cerr << "ans = " << x << "," << y << endl;
        if(x == 4 && y == 0){
            //cerr << "answer success" << endl;
            return 0;
        }

        REP(k,10000){
            if(!m[k]) continue;

            int M[4], t = k;
            REP(j,4){ M[3-j] = t % 10; t /= 10; }

            int x1 = 0, y1 = 0;
            REP(i,4){
                if(N[i] == M[i]){ x1++; continue; }
                if(f[M[i]]){ y1++; continue; }
            }
            if(x != x1 || y != y1) m[k] = false;
        }
    }

    return 0;
}

0