結果

問題 No.24 数当てゲーム
ユーザー Zu_rinZu_rin
提出日時 2019-04-01 22:37:18
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 2 ms / 5,000 ms
コード長 831 bytes
コンパイル時間 693 ms
コンパイル使用メモリ 75,420 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-08-18 01:46:15
合計ジャッジ時間 1,429 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ(β)

テストケース

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

ソースコード

diff #

#include <iostream>
#include <string>
#include <vector>
#include <algorithm>

using namespace std;

int main(void) {
	int num, i = 0, j, k;
	cin >> num;
	string s;
	vector<int> ans(10, 0), qs(5, 16);
	for (; i < num; i++) {
		scanf("%d%d%d%d", &qs[0], &qs[1], &qs[2], &qs[3]);
		cin >> s;
		sort(qs.begin(), qs.end());
		if (s == "YES") {
			for (j = 0, k = 0; j < 10; j++) {
				if (j == qs[k]) {
					k++;
					if (ans[j] == 2)
						continue;
					ans[j] = 1;
				}
				else
					ans[j] = 2;
			}
		}
		else {
			for (j = 0, k = 0; j < 10; j++) {
				if (j == qs[k]) {
					k++;
					if (ans[j] == 2)
						continue;
					ans[j] = 2;
				}
			}
		}
	}
	for (i = 0, k = 10; i < 10; i++) {
		if (ans[i] == 1)
			k = i;
		else if (ans[i] == 0)
			j = i;
	}
	if (k == 10)
		cout << j << "\n";
	else
		cout << k << "\n";
	return 0;
}
0