結果

問題 No.24 数当てゲーム
ユーザー monburan_0401monburan_0401
提出日時 2018-08-29 20:06:21
言語 C
(gcc 12.3.0)
結果
AC  
実行時間 1 ms / 5,000 ms
コード長 1,725 bytes
コンパイル時間 768 ms
コンパイル使用メモリ 28,420 KB
実行使用メモリ 4,372 KB
最終ジャッジ日時 2023-10-11 20:39:22
合計ジャッジ時間 1,492 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ(β)

テストケース

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

ソースコード

diff #

/* 太郎君と二郎君はゲームをしています。

まず最初に二郎君は 0から9までの数字を1つ、心の中で思い浮かべます。

太郎君は、重複しないような0から9までの数字から 4つ 二郎君に提示し、
二郎君は心の中で思い浮かべた数字が、提示された4つの数字の中にあれば 𝑌𝐸𝑆 、
無ければ 𝑁𝑂 と答えます。
これを1ターンとし、次のターンにまた太郎君は4つの数字を提示することを繰り返します。
前に出した数字と同じ数字を提示しても構いません。

入力に太郎君が提示した数字と、二郎君の答えが与えられるので、
二郎君が思い浮かべたであろう数字を出力してください。*/

#include <stdio.h>
int main(void){
	int N;		//	ターン数
	int say[4];	//	数字入力
	char TF[4];	//	yes / no
	int x,y,z;
	int no[10] = {1,1,1,1,1,1,1,1,1,1};
	int ans[10] = {1,1,1,1,1,1,1,1,1,1};
	int max,Nmax;		//	max:ansの最頻値、Nmax:その時の値(0〜9)
	
	scanf("%d",&N);
	
	for (x = 0; x < N; x++){
		scanf("%d%d%d%d",&say[0],&say[1],&say[2],&say[3]);
		scanf("%s",TF);
		if (TF[0] == 'N'){		//	NOの場合
			for (y = 0; y < 4; y++){
				
				no[ say[y] ] = 0;		//	noに不正解のものに0を入れる

			}
		} else {					//	YESの場合
			for (y = 0; y < 4; y++){

				ans[ say[y] ] += 1;		//	ansに候補をカウント

			}
		}
	}
	
	max = ans[0] * no[0];
	Nmax = 0;
	for (x = 0; x < 10; x++){
		ans[x] *= no[x];
		if (max < ans[x]){
			max = ans[x];
			Nmax = x;
		}
	}
	//	確認用
	/*	for (z = 0; z < 10; z++){
			printf("%d",ans[z]);
		}
		printf("\n");	*/
		
	printf("%d\n",Nmax);
	return 0;
	}
0