結果

問題 No.24 数当てゲーム
ユーザー KuphonyKuphony
提出日時 2016-03-16 22:50:05
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 2 ms / 5,000 ms
コード長 1,632 bytes
コンパイル時間 536 ms
コンパイル使用メモリ 65,260 KB
実行使用メモリ 6,676 KB
最終ジャッジ日時 2024-04-08 16:38:40
合計ジャッジ時間 1,062 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

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

int main(int argc, const char * argv[]) {
    int n;
    cin >> n;
    int array[n][4];
    vector<string> strList;
    string tmp;
    int count = 0;
    for(int i = 0; i < n*5;i++){
        if(i%5 == 4){
            cin >> tmp;
            strList.push_back(tmp);
            count++;
        }
        else{
            cin >> array[count][i%5];
        }
    }
    int yescount[10];
    int nocount[10];
    for (int i = 0; i < 10; i++) {
        yescount[i] = 0;
        nocount[i] = 0;
    }
    for (int i = 0; i < n; i++) {
        if(strList[i] == "YES"){
            for (int j = 0; j < 4; j++) {
                yescount[array[i][j]]++;
            }
        }
        else{
            for (int j = 0; j < 4; j++) {
                nocount[array[i][j]]++;
            }
        }
    }
    //ジャッジ
    //判断のパターン
    //1.1つを除きすべてNOになっている
    //2.YESの回数が他より多い
    int result = 0;
    int tmpresult = 0;
    //1番の判定
    int tmpcount = 0;
    for (int i = 0; i < 10; i++) {
        if(nocount[i] == 0){
            tmpresult = i;
        }
        else{
            tmpcount++;
        }
    }
    if(tmpcount == 9){
        result = tmpresult;
    }
    //2番の判定
    int tmpmax = 0;
    for (int i = 0; i < 10; i++) {
        if (yescount[i] > tmpmax && nocount[i] == 0) {
            tmpmax = yescount[i];
            tmpresult = i;
        }
    }
    if(tmpmax >= 1){
        result = tmpresult;
    }
    cout << result;
    cout << "\n";
}
0