結果
| 問題 | No.24 数当てゲーム | 
| コンテスト | |
| ユーザー |  Kuphony | 
| 提出日時 | 2016-03-16 22:50:05 | 
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) | 
| 結果 | 
                                AC
                                 
                             | 
| 実行時間 | 2 ms / 5,000 ms | 
| コード長 | 1,632 bytes | 
| コンパイル時間 | 599 ms | 
| コンパイル使用メモリ | 65,324 KB | 
| 実行使用メモリ | 5,248 KB | 
| 最終ジャッジ日時 | 2024-10-01 08:48:38 | 
| 合計ジャッジ時間 | 941 ms | 
| ジャッジサーバーID (参考情報) | judge3 / judge4 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| other | AC * 10 | 
ソースコード
#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";
}
            
            
            
        