結果

問題 No.305 鍵(2)
ユーザー Konton7
提出日時 2020-01-14 23:16:46
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 42 ms / 2,000 ms
コード長 747 bytes
コンパイル時間 2,419 ms
コンパイル使用メモリ 193,544 KB
最終ジャッジ日時 2025-01-08 18:05:08
ジャッジサーバーID
(参考情報)
judge1 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 13
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:28:28: warning: ‘collect_max’ may be used uninitialized [-Wmaybe-uninitialized]
   28 |         ans += collect_max + '0';
      |                ~~~~~~~~~~~~^~~~~
main.cpp:9:18: note: ‘collect_max’ was declared here
    9 |     int collect, collect_max, ret_collect;
      |                  ^~~~~~~~~~~

ソースコード

diff #

#include <bits/stdc++.h>

using namespace std;
typedef long long ll;



int main(){
    int collect, collect_max, ret_collect;
    int const digit = 10;
    string s, ans, ret_string;
    string const s0 = "0000000000";
    for (int i = 0; i < digit; i++){
        s = s0;
        collect = -1;
        for (int j = 0; j < digit; j++){
            cout << s << endl;
            cin >> ret_collect >> ret_string;
            if (ret_string == "unlocked")
                return 0;
            else{
                if (ret_collect > collect)
                    collect_max = j;
                collect = ret_collect;
            }
            s[i]++;
        }
        ans += collect_max + '0';
    }
    
    cout << ans << endl;
    return 0;
}
0