結果

問題 No.24 数当てゲーム
コンテスト
ユーザー latte0119
提出日時 2015-04-30 21:31:11
言語 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  
実行時間 2 ms / 5,000 ms
コード長 589 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 1,279 ms
コンパイル使用メモリ 177,036 KB
実行使用メモリ 7,716 KB
最終ジャッジ日時 2026-03-27 02:23:06
合計ジャッジ時間 2,079 ms
ジャッジサーバーID
(参考情報)
judge1_0 / judge3_1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 10
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function 'int main()':
main.cpp:27:11: warning: 'val' may be used uninitialized [-Wmaybe-uninitialized]
   27 |     printf("%d\n",val);
      |     ~~~~~~^~~~~~~~~~~~
main.cpp:20:20: note: 'val' was declared here
   20 |     int ma=INT_MIN,val;
      |                    ^~~

ソースコード

diff #
raw source code

#include<bits/stdc++.h>
using namespace std;
int main(){
    int cnt[10]={0},N;
    scanf("%d",&N);
    for(int i=0;i<N;i++){
        int a[4];
        char str[8];
        for(int j=0;j<4;j++)scanf("%d",&a[j]);
        scanf("%s",str);
        if(str[0]=='N'){
            for(int j=0;j<4;j++){
                cnt[a[j]]=INT_MIN;
            }
        }
        else{
            for(int j=0;j<4;j++)cnt[a[j]]++;
        }
    }
    int ma=INT_MIN,val;
    for(int i=0;i<10;i++){
        if(cnt[i]>ma){
            ma=cnt[i];
            val=i;
        }
    }
    printf("%d\n",val);

}
0