結果

問題 No.24 数当てゲーム
ユーザー LavenderLavender
提出日時 2019-08-31 07:24:04
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 2 ms / 5,000 ms
コード長 968 bytes
コンパイル時間 530 ms
コンパイル使用メモリ 65,452 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-08-15 16:06:40
合計ジャッジ時間 1,197 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,384 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 AC 1 ms
4,380 KB
testcase_04 AC 2 ms
4,380 KB
testcase_05 AC 2 ms
4,380 KB
testcase_06 AC 1 ms
4,376 KB
testcase_07 AC 2 ms
4,376 KB
testcase_08 AC 1 ms
4,380 KB
testcase_09 AC 1 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
using namespace std;
int main()
{
    int n;
    int a[4];
    int num[10];
    int count;
    int temp;
    string s;
    cin >> n;
    for(int i=0;i<10;i++){
        num[i]=i;
    }
    for(int i=0;i<n;i++){
        //  入力の受付
        for(int i=0;i<4;i++){
            cin >> a[i];
        }
        cin >> s;
        //  NOの処理
        if(s=="NO"){
            for(int i=0;i<4;i++){
                num[a[i]] = -1;
            }
        }
        //  YESの処理
        if(s=="YES"){
            for(int i=0;i<10;i++){
                if(a[0]!=num[i]&&a[1]!=num[i]&&a[2]!=num[i]&&a[3]!=num[i]&&num[i]!=-1){
                    num[i]=-1;
                }
            }
        }
        count=0;
        for(int i=0;i<10;i++){
            if(num[i]!=-1){
                count++;
                temp=num[i];
            }
        }
        if(count==1){
            cout << temp << endl;
            return 0;
        }
    }
}
0