結果

問題 No.305 鍵(2)
ユーザー kichirb3
提出日時 2018-03-09 19:47:15
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 29 ms / 2,000 ms
コード長 961 bytes
コンパイル時間 709 ms
コンパイル使用メモリ 72,440 KB
実行使用メモリ 25,220 KB
平均クエリ数 53.08
最終ジャッジ日時 2024-07-17 01:36:16
合計ジャッジ時間 2,202 ms
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 13
権限があれば一括ダウンロードができます

ソースコード

diff #

// No.305 鍵(2)
// https://yukicoder.me/problems/no/305
//

#include <iostream>
#include <vector>
#include <sstream>
using namespace std;


int check_keys(vector<int>& numbers);


int main() {
    std::cin.tie(nullptr);
    std::ios::sync_with_stdio(false);

    vector<int> numbers(10, 0);
    int prev_res = check_keys(numbers);

    for (auto keta = 0; keta < 10; ++keta) {
        if (prev_res == 10)
            break;
        for (auto i = 0; i < 10; ++i) {
            numbers[keta] = i;
            int res = check_keys(numbers);
            if (res > prev_res) {
                prev_res = res;
                break;
            } else if (res < prev_res) {
                numbers[keta] -= 1;
                break;
            }
        }
    }
}


int check_keys(vector<int>& numbers) {
    stringstream ss;
    for (auto n: numbers)
        cout << n;
    cout << flush << endl;

    int res;
    string s;
    cin >> res >> s;
    return res;
}
0