結果

問題 No.305 鍵(2)
ユーザー tottoripapertottoripaper
提出日時 2018-01-07 02:01:28
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
TLE  
実行時間 -
コード長 1,206 bytes
コンパイル時間 617 ms
コンパイル使用メモリ 70,932 KB
実行使用メモリ 24,336 KB
平均クエリ数 5419.92
最終ジャッジ日時 2023-09-23 15:35:47
合計ジャッジ時間 9,041 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 28 ms
24,024 KB
testcase_01 TLE -
testcase_02 AC 328 ms
24,084 KB
testcase_03 AC 1,788 ms
23,796 KB
testcase_04 TLE -
testcase_05 -- -
testcase_06 -- -
testcase_07 -- -
testcase_08 -- -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

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

int ask(std::string S){
    std::cout << S << std::endl;

    int N;
    std::string T;
    std::cin >> N >> T;

    return N;
}

string find(string prefix, string suffix){
    for(int i=0;i<100000;++i){
        string s = to_string(i);
        while(s.size() < 5){
            s = '0' + s;
        }

        if(ask(prefix + s + suffix) == 5){
            return s;
        }
    }

    return "-1";
}

int main(){
    string notMatchedSuffix;
    {
        int matched = 100;
        for(int i=0;i<10;++i){
            string s = string(5, '0' + i);
            int n = ask(string(5, '0') + s);
            if(n < matched){
                notMatchedSuffix = s;
                matched = n;
            }
        }
    }
    
    string notMatchedPrefix;
    {
        int matched = 100;
        for(int i=0;i<10;++i){
            string s = string(5, '0' + i);
            int n = ask(s + string(5, '0'));
            if(n < matched){
                notMatchedPrefix = s;
                matched = n;
            }
        }
    }

    string res = find("", notMatchedSuffix) + find(notMatchedPrefix, "");
    std::cout << res << std::endl;
}
0