結果

問題 No.24 数当てゲーム
コンテスト
ユーザー Naoyk1212
提出日時 2016-08-12 12:22:16
言語 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
コード長 619 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 935 ms
コンパイル使用メモリ 176,004 KB
実行使用メモリ 6,400 KB
最終ジャッジ日時 2026-05-07 20:28:58
合計ジャッジ時間 1,720 ms
ジャッジサーバーID
(参考情報)
judge3_0 / judge2_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 10
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function 'int main()':
main.cpp:37:17: warning: 'max_num' may be used uninitialized [-Wmaybe-uninitialized]
   37 |         cout << max_num << endl;
      |                 ^~~~~~~
main.cpp:28:13: note: 'max_num' was declared here
   28 |         int max_num;
      |             ^~~~~~~

ソースコード

diff #
raw source code

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

int main(){
	int n;
	cin >> n;
	bool num[10];
	int count[10];
	fill_n(num, 10, true);
	fill_n(count, 10, 0);
	int a, b, c, d;
	string str;
	for(int i = 0; i < n; i++){
		cin >> a >> b >> c >> d >> str;
		if(str == "NO"){
			num[a] = false;
			num[b] = false;
			num[c] = false;
			num[d] = false;
		}else{
			count[a]++;
			count[b]++;
			count[c]++;
			count[d]++;
		}
	}
	int max_count = -1;
	int max_num;
	for(int i = 0; i < 10; i++){
		if(num[i] == true){
			if(max_count < count[i]){
				max_count = count[i];
				max_num = i;
			}
		}
	}
	cout << max_num << endl;
}

0