結果

問題 No.305 鍵(2)
ユーザー cormorancormoran
提出日時 2016-05-31 18:17:34
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 31 ms / 2,000 ms
コード長 597 bytes
コンパイル時間 465 ms
コンパイル使用メモリ 65,472 KB
実行使用メモリ 24,216 KB
平均クエリ数 86.69
最終ジャッジ日時 2023-09-24 00:01:59
合計ジャッジ時間 1,885 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 31 ms
23,916 KB
testcase_01 AC 27 ms
23,916 KB
testcase_02 AC 28 ms
23,508 KB
testcase_03 AC 27 ms
23,520 KB
testcase_04 AC 27 ms
24,216 KB
testcase_05 AC 28 ms
23,352 KB
testcase_06 AC 25 ms
24,036 KB
testcase_07 AC 27 ms
23,340 KB
testcase_08 AC 28 ms
23,376 KB
testcase_09 AC 27 ms
24,120 KB
testcase_10 AC 27 ms
23,760 KB
testcase_11 AC 28 ms
23,652 KB
testcase_12 AC 27 ms
23,604 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:28:14: warning: ‘ok’ may be used uninitialized in this function [-Wmaybe-uninitialized]
         n[i] = ok;

ソースコード

diff #

#include <iostream>
#include <vector>
#include <string>
#include <iomanip>
using namespace std;

int push(vector<int> &n) {
    for(int i : n) cout << i;
    cout << endl;
    cout.flush();
    int x;
    string s;
    cin >> x >> s;
    return x;
}

int main() {
    vector<int> n(10);
    
    for(int i = 0; i < 10; i++) {
        int mx = 0, ok;
        for(int j = 0; j < 10; j++) {
            n[i] = j;
            int ret = push(n);
            if(ret == 10) return 0;
            if(ret >= mx) mx = ret, ok = j;            
        }
        n[i] = ok;
    }
    push(n);
    return 0;
}
0