結果

問題 No.296 n度寝
ユーザー subsnsubsn
提出日時 2023-05-30 10:04:14
言語 C
(gcc 12.3.0)
結果
RE  
実行時間 -
コード長 1,700 bytes
コンパイル時間 156 ms
コンパイル使用メモリ 29,220 KB
実行使用メモリ 4,500 KB
最終ジャッジ日時 2023-08-28 00:28:31
合計ジャッジ時間 2,604 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 RE -
testcase_01 RE -
testcase_02 RE -
testcase_03 RE -
testcase_04 WA -
testcase_05 RE -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 RE -
testcase_10 WA -
testcase_11 RE -
testcase_12 RE -
testcase_13 WA -
testcase_14 RE -
testcase_15 RE -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <stdio.h>
#include <malloc.h>
char str[60000];
int str_len = 0;

/// <summary>
/// グローバル変数strの中身を入力された文字列で上書きする
/// </summary>
void ReadString() {
	char c = getchar();
	str_len = 0;

	while (c != '\n') {
		str[str_len] = c;
		c = getchar();
		str_len++;
	}
}

/// <summary>
/// 入力された数字を返す
/// </summary>
/// <returns></returns>
int ReadNum() {
	int negate = 0;
	char c = getchar();
	int num = 0;
	int numCnt = 0;
	while (c != '\n') {
		if (c == '-') {
			negate = 1;
		}
		else {
			num = num * 10 + c - '0';
		}

		c = getchar();
	}
	if (negate == 1) {
		num *= -1;
	}
	return num;
}

/// <summary>
/// [値][空白][値][空白][値][空白][値][空白][YES/NO]
/// のフォーマットで入力させYESであれば入力された値の中に含まれないnumsの中身を-1(除外)にする
/// </summary>
/// <param name="nums"></param>
void ExtractNums(int* nums) {
	ReadString();
	for (int i = 0;i < 7;i++) {
		if (str[i] == ' ') {
			continue;
		}
		if (str[8] == 'N') {
			for (int j = 0;j < 10;j++) {
				if (str[i] - '0' == nums[j]) {
					nums[j] = -1;
				}
			}
		}
		else {
			for (int j = 0;j < 10;j++) {
				for (int k = 0;k < 7;k++) {
					if (str[k] == ' ') {
						continue;
					}
					if (nums[j] == str[k] - '0') {
						break;
					}
					if (k == 6) {
						nums[j] = -1;
					}
				}
			}
		}

	}
}
int main()
{
	int nums[10] = {0,1,2,3,4,5,6,7,8,9};
	int n = ReadNum();
	for (int i = 0;i < n;i++) {//ターン数分ループして、絞り込みを毎回行う
		ExtractNums(nums);
	}
	for (int i = 0;i < 10;i++) {
		if (nums[i] != -1) {
			printf("%d", nums[i]);
			printf(" ");
		}

	}
}

0