結果
問題 | No.355 数当てゲーム(2) |
ユーザー | 14番 |
提出日時 | 2016-05-27 07:52:44 |
言語 | C#(csc) (csc 3.9.0) |
結果 |
AC
|
実行時間 | 98 ms / 2,000 ms |
コード長 | 7,008 bytes |
コンパイル時間 | 3,024 ms |
コンパイル使用メモリ | 114,432 KB |
実行使用メモリ | 40,208 KB |
平均クエリ数 | 25.06 |
最終ジャッジ日時 | 2023-09-23 23:57:01 |
合計ジャッジ時間 | 11,321 ms |
ジャッジサーバーID (参考情報) |
judge12 / judge13 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 89 ms
40,132 KB |
testcase_01 | AC | 95 ms
37,916 KB |
testcase_02 | AC | 98 ms
37,920 KB |
testcase_03 | AC | 95 ms
37,616 KB |
testcase_04 | AC | 96 ms
37,732 KB |
testcase_05 | AC | 95 ms
37,380 KB |
testcase_06 | AC | 93 ms
37,552 KB |
testcase_07 | AC | 91 ms
37,996 KB |
testcase_08 | AC | 90 ms
37,888 KB |
testcase_09 | AC | 92 ms
37,616 KB |
testcase_10 | AC | 94 ms
37,904 KB |
testcase_11 | AC | 90 ms
38,096 KB |
testcase_12 | AC | 93 ms
38,020 KB |
testcase_13 | AC | 93 ms
38,288 KB |
testcase_14 | AC | 93 ms
39,928 KB |
testcase_15 | AC | 91 ms
37,440 KB |
testcase_16 | AC | 93 ms
37,544 KB |
testcase_17 | AC | 95 ms
39,552 KB |
testcase_18 | AC | 92 ms
39,668 KB |
testcase_19 | AC | 91 ms
38,276 KB |
testcase_20 | AC | 93 ms
37,612 KB |
testcase_21 | AC | 92 ms
40,012 KB |
testcase_22 | AC | 91 ms
37,396 KB |
testcase_23 | AC | 91 ms
39,944 KB |
testcase_24 | AC | 92 ms
35,544 KB |
testcase_25 | AC | 91 ms
40,208 KB |
testcase_26 | AC | 91 ms
39,768 KB |
testcase_27 | AC | 89 ms
38,232 KB |
testcase_28 | AC | 93 ms
37,972 KB |
testcase_29 | AC | 95 ms
38,028 KB |
testcase_30 | AC | 94 ms
37,560 KB |
testcase_31 | AC | 92 ms
40,000 KB |
testcase_32 | AC | 95 ms
39,600 KB |
testcase_33 | AC | 91 ms
37,740 KB |
testcase_34 | AC | 92 ms
40,136 KB |
testcase_35 | AC | 95 ms
35,608 KB |
testcase_36 | AC | 94 ms
39,540 KB |
testcase_37 | AC | 91 ms
39,804 KB |
testcase_38 | AC | 93 ms
36,084 KB |
testcase_39 | AC | 93 ms
38,120 KB |
testcase_40 | AC | 91 ms
37,860 KB |
testcase_41 | AC | 92 ms
38,096 KB |
testcase_42 | AC | 91 ms
37,708 KB |
testcase_43 | AC | 94 ms
37,792 KB |
testcase_44 | AC | 95 ms
39,588 KB |
testcase_45 | AC | 95 ms
35,564 KB |
testcase_46 | AC | 95 ms
39,984 KB |
testcase_47 | AC | 96 ms
37,948 KB |
testcase_48 | AC | 95 ms
38,080 KB |
testcase_49 | AC | 95 ms
37,836 KB |
testcase_50 | AC | 93 ms
39,476 KB |
testcase_51 | AC | 91 ms
38,036 KB |
コンパイルメッセージ
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; using System.Text; using System.Linq; class Program { public void Proc() { Reader.IsDebug = false; this.FirstStep(); } private bool FirstStep(){ Console.WriteLine("1 2 3 4"); int[] ret1 = GetInput(); if(ret1[0] == 4) { return true; } else if(ret1.Sum() == 4) { this.InList.AddRange(new int[]{1,2,3,4}); return ProcLast4(); } else if(ret1.Sum() == 0) { this.OutList.AddRange(new int[]{1,2,3,4}); return this.ProcOut3(); } else if(ret1.Sum() == 1) { return this.ProcIn1_Out3(new int[]{1,2,3,4}); } else if(ret1.Sum() == 3) { return this.ProcIn3_Out1(new int[]{1,2,3,4}); } Console.WriteLine("5 6 7 8"); int[] ret2 = GetInput(); if(ret2[0] == 4) { return true; } else if(ret2.Sum() == 4) { this.InList.AddRange(new int[]{5,6,7,8}); return ProcLast4(); } else if(ret2.Sum() == 0) { this.OutList.AddRange(new int[]{5,6,7,8}); return this.ProcOut3(); } else if(ret2.Sum() == 1) { return this.ProcIn1_Out3(new int[]{5,6,7,8}); } else if(ret2.Sum() == 3) { return this.ProcIn3_Out1(new int[]{5,6,7,8}); } Console.WriteLine("9 0 1 2"); int[] ret3 = GetInput(); if(ret3[0] == 4) { return true; } else if(ret3.Sum() == 4) { this.InList.AddRange(new int[]{9,0,1,2}); return ProcLast4(); } else if(ret3.Sum() == 0) { this.OutList.AddRange(new int[]{9,0,1,2}); return this.ProcOut3(); } else if(ret3.Sum() == 1) { return this.ProcIn1_Out3(new int[]{9,0,1,2}); } else if(ret3.Sum() == 3) { return this.ProcIn3_Out1(new int[]{9,0,1,2}); } List<int> ng = new List<int>(new int[]{9,0, 3, 4}); this.OutList.AddRange(ng); return this.ProcOut3(); } private bool ProcIn3_Out1(int[] target) { List<int> otherList = new List<int>(BaseNumList.Where(a=>!target.Contains(a)).Take(2)); foreach (int item in target) { int min = int.MaxValue; foreach (int hikaku in otherList) { List<int> subList = new List<int>(target); subList.Remove(item); subList.Add(hikaku); Console.WriteLine(string.Join(" ", subList)); int[] ret = GetInput(); if(ret[0] == 4) { return true; } if(ret.Sum() == 4) { this.InList.Clear(); this.InList.AddRange(subList); return this.ProcLast4(); } min = Math.Min(min, ret.Sum()); } if(min == 3) { this.InList.Clear(); this.InList.AddRange(target); this.InList.Remove(item); return this.ProcIn3(); } } return true; } private bool ProcIn3() { List<int> target = new List<int>(BaseNumList.Where(a=>!InList.Contains(a))); foreach (int item in target) { List<int> temp = new List<int>(InList.Take(3)); temp.Add(item); Console.WriteLine(string.Join(" ", temp)); int[] ret = GetInput(); if(ret[0] == 4) { return true; } if(ret.Sum() == 4) { InList.Add(item); return this.ProcLast4(); } } return true; } private bool ProcIn1_Out3(int[] target) { List<int> hikaku = new List<int>(BaseNumList.Where(a=>!target.ToList().Contains(a)).Take(4)); for(int i=0; i<target.Length; i++) { int maxVal = int.MaxValue; for(int j=0; j<hikaku.Count; j++) { List<int> tmp = new List<int>(target); tmp.RemoveAt(i); tmp.Add(hikaku[j]); Console.WriteLine(string.Join(" ", tmp)); int[] ret = GetInput(); maxVal = Math.Min(maxVal, ret.Sum()); } if(maxVal == 0) { this.OutList.Clear(); this.OutList.AddRange(target); this.OutList.RemoveAt(i); return this.ProcOut3(); } } return true; } private bool ProcOut3() { List<int> target = new List<int>(BaseNumList.Where(a=>!OutList.Contains(a))); foreach (int num in target) { List<int> tmp = new List<int>(this.OutList.Take(3)); tmp.Add(num); Console.WriteLine(string.Join(" ", tmp)); int[] ret = GetInput(); if(ret.Sum() > 0) { if(!InList.Contains(num)) { InList.Add(num); if(InList.Count == 4) { return ProcLast4(); } } } } return true; } /// 入力候補4つが確定している private bool ProcLast4() { OutList.Clear(); OutList.AddRange(BaseNumList); InList.ForEach(a=>OutList.Remove(a)); int[] ans = new int[4]; for(int i=0; i<InList.Count; i++) { for(int j=0; j<4; j++) { List<int> tmp = new List<int>(); tmp.AddRange(OutList.Take(3)); tmp.Insert(j, InList[i]); Console.WriteLine(string.Join(" ", tmp)); int[] ret = this.GetInput(); if(ret[0] == 1) { ans[j] = InList[i]; break; } } } Console.WriteLine(string.Join(" ", ans)); return true; } private int[] GetInput() { return Reader.ReadLine().Split(' ').Select(a=>int.Parse(a)).ToArray(); } private List<int> OutList = new List<int>(); private List<int> InList = new List<int>(); private int[] BaseNumList = new int[]{0,1,2,3,4,5,6,7,8,9}; public class Reader { public static bool IsDebug = true; private static String PlainInput = @" 2 3 "; private static System.IO.StringReader Sr = null; public static string ReadLine() { if (IsDebug) { if (Sr == null) { Sr = new System.IO.StringReader(PlainInput.Trim()); } return Sr.ReadLine(); } else { return Console.ReadLine(); } } } static void Main() { Program prg = new Program(); prg.Proc(); } }