結果
| 問題 |
No.24 数当てゲーム
|
| コンテスト | |
| ユーザー |
bayashiko_r
|
| 提出日時 | 2018-11-07 00:41:52 |
| 言語 | C#(csc) (csc 3.9.0) |
| 結果 |
AC
|
| 実行時間 | 29 ms / 5,000 ms |
| コード長 | 2,088 bytes |
| コンパイル時間 | 981 ms |
| コンパイル使用メモリ | 111,320 KB |
| 実行使用メモリ | 26,180 KB |
| 最終ジャッジ日時 | 2024-11-20 20:37:22 |
| 合計ジャッジ時間 | 1,830 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 10 |
コンパイルメッセージ
Microsoft (R) Visual C# Compiler version 3.9.0-6.21124.20 (db94f4cc) Copyright (C) Microsoft Corporation. All rights reserved.
ソースコード
using System;
using System.Collections.Generic;
class Program {
static void Main(string[] args) {
//入力
int N = int.Parse(Console.ReadLine());
//N行の入力
string[] s = new string[N];
int[] A = new int[N];
int[] B = new int[N];
int[] C = new int[N];
int[] D = new int[N];
string[] R = new string[N];
for (int i = 0; i < N; i++) {
s[i] = Console.ReadLine();
A[i] = int.Parse(s[i].Split(' ')[0]);
B[i] = int.Parse(s[i].Split(' ')[1]);
C[i] = int.Parse(s[i].Split(' ')[2]);
D[i] = int.Parse(s[i].Split(' ')[3]);
R[i] = s[i].Split(' ')[4];
}
//回答となりうる数字のリスト
List<int> ans = new List<int> { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 };
//回答が一つになるまで続ける
while(ans.Count != 1) {
for (int i = 0; i < N; i++) {
if (R[i] == "YES") {
List<int> temp = new List<int> {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
//6つの数字よりなる、取り除く数字のリストを作る
temp.Remove(A[i]);
temp.Remove(B[i]);
temp.Remove(C[i]);
temp.Remove(D[i]);
//ansリストから、6つの数字を取り除く
for (int j = 0; j < 6; j++) {
if (ans.Contains(temp[j])){
ans.Remove(temp[j]);
}
}
} else if (R[i] == "NO") {
//ansリストから、4つの数字を取り除く
if (ans.Contains(A[i])) ans.Remove(A[i]);
if (ans.Contains(B[i])) ans.Remove(B[i]);
if (ans.Contains(C[i])) ans.Remove(C[i]);
if (ans.Contains(D[i])) ans.Remove(D[i]);
}
}
}
//出力
Console.WriteLine(ans[0]);
}
}
bayashiko_r