結果

問題 No.24 数当てゲーム
コンテスト
ユーザー kanTiramisu
提出日時 2019-05-10 15:41:07
言語 C++11
(gcc 15.2.0 + boost 1.89.0)
コンパイル:
g++-15 -O2 -lm -std=gnu++11 -Wuninitialized -DONLINE_JUDGE -o a.out _filename_
実行:
./a.out
結果
AC  
実行時間 1 ms / 5,000 ms
コード長 852 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 829 ms
コンパイル使用メモリ 180,116 KB
実行使用メモリ 6,272 KB
最終ジャッジ日時 2026-03-23 04:50:23
合計ジャッジ時間 1,418 ms
ジャッジサーバーID
(参考情報)
judge2_0 / judge1_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 10
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function 'int main()':
main.cpp:48:13: warning: 'res' may be used uninitialized [-Wmaybe-uninitialized]
   48 |     cout << res <<endl;
      |             ^~~
main.cpp:11:9: note: 'res' was declared here
   11 |     int res;
      |         ^~~

ソースコード

diff #
raw source code

#include "bits/stdc++.h"
using namespace std;


int main() {
    int N;
    int count=4;
    int A[count];
    int number[10];
    char str[100];
    int res;
    int max= -1000;
    for(int i = 0; i < 10; i++)
    {
        number[i] = 0;
    }

    cin >> N;

    for(int i=0;i < N; i++){
        for(int j= 0; j < count; j++)
        {
            cin >> A[j];
        }

        cin >> str; 

        if (!strcmp(str,"YES")){
            for(int j= 0; j < count; j++){
                number[A[j]]++;
            }      
        }
        else{
            for(int j= 0; j < count; j++){
                number[A[j]]=number[A[j]]-100000;
            }              
        }
    }

    for(int i = 0; i < 10; i++)
    {
        if(number[i] > max){
            max = number[i];
            res = i;
        }
    }

    cout << res <<endl;
    

}
0