結果

問題 No.305 鍵(2)
ユーザー MJDigitMJDigit
提出日時 2015-11-29 20:30:36
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 30 ms / 2,000 ms
コード長 1,423 bytes
コンパイル時間 1,783 ms
コンパイル使用メモリ 58,572 KB
実行使用メモリ 24,312 KB
平均クエリ数 34.38
最終ジャッジ日時 2023-09-23 22:12:17
合計ジャッジ時間 2,599 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 30 ms
23,316 KB
testcase_01 AC 28 ms
23,940 KB
testcase_02 AC 28 ms
23,592 KB
testcase_03 AC 27 ms
24,312 KB
testcase_04 AC 27 ms
23,724 KB
testcase_05 AC 25 ms
24,216 KB
testcase_06 AC 25 ms
24,264 KB
testcase_07 AC 26 ms
23,544 KB
testcase_08 AC 27 ms
23,628 KB
testcase_09 AC 27 ms
23,376 KB
testcase_10 AC 27 ms
24,048 KB
testcase_11 AC 27 ms
24,060 KB
testcase_12 AC 27 ms
24,048 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <algorithm>
#include <string>

using namespace std;

int main() {
    const int digits = 10;
    int  n[10];
    int  ans[digits] = {};
    int  matched[digits] = {};
    int  maxmatch;
    string rep;

    for (int i = 0; i < 10; i++) {
        for (int digit = 0; digit < digits; digit++) {
            cout << i;
        }
        cout << endl;
        cin >> n[i] >> rep;

        if(rep == "unlocked") {
            return 0;
        }
    }

    for (int i = 1; i < 10; i++) {
        if (n[i] == 0) {
            continue;
        }

        maxmatch = 0;
        for (int j = 0; j < digits; j++) {
            if (ans[j] != 0) {
                continue;
            }
            for (int digit = 0; digit < digits; digit++) {
                if (digit == j) {
                    cout << i;
                } else {
                    cout << ans[digit];
                }
            }
            cout << endl;

            cin >> matched[j] >> rep;
            if(rep == "unlocked") {
                return 0;
            }

            maxmatch = max (matched[j], maxmatch);
        }

        for (int j = 0; j < digits; j++) {
            if (matched[j] == maxmatch) {
                ans[j] = i;
            }
            matched[j] = 0;
        }
    }

    for (int digit = 0; digit < digits; digit++) {
        cout << ans[digit];
    }
    cout << endl;

    return 0;
}
0