結果

問題 No.305 鍵(2)
ユーザー lunnearlunnear
提出日時 2018-12-12 15:41:28
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 31 ms / 2,000 ms
コード長 1,321 bytes
コンパイル時間 495 ms
コンパイル使用メモリ 52,224 KB
実行使用メモリ 24,300 KB
平均クエリ数 32.15
最終ジャッジ日時 2023-09-24 02:01:43
合計ジャッジ時間 1,941 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 31 ms
24,264 KB
testcase_01 AC 27 ms
23,988 KB
testcase_02 AC 26 ms
23,388 KB
testcase_03 AC 27 ms
24,288 KB
testcase_04 AC 26 ms
24,240 KB
testcase_05 AC 27 ms
24,300 KB
testcase_06 AC 25 ms
23,364 KB
testcase_07 AC 26 ms
23,388 KB
testcase_08 AC 27 ms
24,000 KB
testcase_09 AC 27 ms
23,640 KB
testcase_10 AC 26 ms
23,508 KB
testcase_11 AC 28 ms
23,352 KB
testcase_12 AC 28 ms
23,628 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <string.h>

void Input(char put[])
{
    char s[11] = {0};
    for(int i = 0; i < 10; i++)
    {
        s[i] = put[i] + '0';
    }
    
    std::cout << s << std::endl;
    std::cout << std::flush;
}

int main()
{
    char lock[10] = {0};
    bool fix[10] = {false};
    
    int prev = 0;
    int in1 = 0;
    char in2[9];
    
    
    while(1)
    {
        Input(lock);
        std::cin >> in1 >> in2;
        
        if(in1 == 10)
            break;
        
        if(in1 > prev)
        {
            char l[10];
            memcpy(l, lock, 10);
            for(int i = 0; i < 10; i++)
            {
                if(!fix[i])
                {
                    l[i]++;
                    Input(l);
                    
                    int in;
                    std::cin >> in >> in2;
                    
                    if(in == 10)
                        return 0;
                    
                    if(in < in1)
                        fix[i] = true;
                    
                    l[i]--;
                }
            }
        }
        
        prev = in1;
        
        for(int i = 0; i < 10; i++)
        {
            if(fix[i])
                continue;
            
            lock[i]++;
        }
        
    }
    
    return 0;
}
0