結果

問題 No.24 数当てゲーム
ユーザー fujitafujita
提出日時 2023-04-27 15:09:19
言語 C#
(.NET 8.0.203)
結果
WA  
実行時間 -
コード長 4,716 bytes
コンパイル時間 8,565 ms
コンパイル使用メモリ 169,024 KB
実行使用メモリ 185,956 KB
最終ジャッジ日時 2024-04-28 07:54:57
合計ジャッジ時間 9,227 ms
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 43 ms
29,696 KB
testcase_01 AC 42 ms
30,464 KB
testcase_02 AC 41 ms
30,464 KB
testcase_03 WA -
testcase_04 AC 41 ms
30,452 KB
testcase_05 AC 41 ms
30,440 KB
testcase_06 AC 41 ms
30,208 KB
testcase_07 AC 43 ms
30,208 KB
testcase_08 AC 43 ms
30,564 KB
testcase_09 AC 42 ms
185,956 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
  復元対象のプロジェクトを決定しています...
  /home/judge/data/code/main.csproj を復元しました (79 ms)。
MSBuild のバージョン 17.9.6+a4ecab324 (.NET)
/home/judge/data/code/Main.cs(14,31): warning CS0219: 変数 'z' は割り当てられていますが、その値は使用されていません [/home/judge/data/code/main.csproj]
  main -> /home/judge/data/code/bin/Release/net8.0/main.dll
  main -> /home/judge/data/code/bin/Release/net8.0/publish/

ソースコード

diff #

using System.Collections.Generic;
using System;
using System.Linq;
using System.Drawing;

namespace yukicoder
{
    class Program
    {

        static void Main(string[] args)
        {
            int N = int.Parse(Console.ReadLine());
            int m = 0, x = 1, z = 1;
            var list = new List<string>() {"0", "1", "2", "3", "4", "5",
                                             "6" , "7" , "8" , "9" ,};
            var anslist = new List<string>();
            var newanslist = new List<string>();
            for (int i = 0; i < N; i++)
            {
                var a = Console.ReadLine();
                var A = a.Split();
                if (a.Contains("YES"))
                {
                    anslist.Add(A[0]);
                    anslist.Add(A[1]);
                    anslist.Add(A[2]);
                    anslist.Add(A[3]);
                    anslist.Sort();
                    
                }
                else if (a.Contains("NO"))
                {
                    list.Remove(A[0]);
                    list.Remove(A[1]);
                    list.Remove(A[2]);
                    list.Remove(A[3]);
                    
                }
            }
            
            //新しいリストにanslistで重複している数字を入れる
            for(int j = 0; j < anslist.Count - 1; j++)
            {
                if (anslist[j] == anslist[x]) 
                {
                    x++;
                    newanslist.Add(anslist[j]);
                }
                else
                {
                    x++;
                    continue;
                }
                
            }
            //listの要素が1つかnewanslistの要素が1つか
            if(list.Count == 1 || newanslist.Count == 1)
            {
                if(list.Count == 1)
                {
                    Console.WriteLine(list[0]);
                }
                else
                {
                    Console.WriteLine(newanslist[0]);
                }
            }else if (list.Count > 1 && newanslist.Count > 1)
            {//listの要素が1つ以上かnewanslistの要素が1つ以上か
                if (newanslist.Count > list.Count || !(anslist.Count < 1))
                {
                    for (int i = 0; i < list.Count; i++)
                    {
                        
                        for(int j = 0; j < newanslist.Count; j++)
                        {
                            

                            for (m = 0; m < newanslist.Count - 1; m++)
                            {
                                if (newanslist[m].Equals(newanslist[m + 1]))
                                {
                                    Console.WriteLine(newanslist[m]);
                                    break;
                                }
                               
                            }
                            
                            if (!(m == 0))
                            {
                                break;
                            }
                        }
                        for (int zz = 0; zz < newanslist.Count - 1;zz++)
                        {
                            if (list[i].Equals(newanslist[zz]))
                            {
                                Console.WriteLine(list[i]);
                                break;
                            }
                        }
                        
                    }
                }
                
            }
            else if (list.Count > 1 && newanslist.Count > 1 && anslist.Count > 1)
            {
                for (int i = 0; i < list.Count; i++)
                {
                    for (int j = 0; j < newanslist.Count; j++)
                    {
                        for(int k = 0; k < anslist.Count; k++)
                        { 
                            if (list[i].Equals(newanslist[j]) && list[i].Equals(anslist[j]))
                            {
                                Console.WriteLine(list[i]);
                                break;
                            }
                        }
                    }
                }
            }
            else if (newanslist.Count == 0 )
            {
                for (int i = 0; i < list.Count; i++)
                {
                    for (int j = 0; j < anslist.Count; j++)
                    {
                        if (list[i].Equals(anslist[j]))
                        {
                            Console.WriteLine(list[i]);
                            break;
                        }
                    }
                }
            }
        }
    }
}
0