結果

問題 No.624 Santa Claus and The Last Dungeon
ユーザー 紙ぺーぱー紙ぺーぱー
提出日時 2017-12-19 23:46:33
言語 C#(csc)
(csc 3.9.0)
結果
AC  
実行時間 137 ms / 2,000 ms
コード長 3,061 bytes
コンパイル時間 2,448 ms
コンパイル使用メモリ 110,672 KB
実行使用メモリ 42,404 KB
平均クエリ数 418.86
最終ジャッジ日時 2023-09-23 15:18:13
合計ジャッジ時間 9,453 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 137 ms
39,712 KB
testcase_01 AC 134 ms
42,204 KB
testcase_02 AC 134 ms
40,304 KB
testcase_03 AC 134 ms
37,696 KB
testcase_04 AC 135 ms
40,256 KB
testcase_05 AC 135 ms
41,780 KB
testcase_06 AC 133 ms
39,732 KB
testcase_07 AC 134 ms
40,340 KB
testcase_08 AC 135 ms
40,372 KB
testcase_09 AC 133 ms
40,212 KB
testcase_10 AC 134 ms
39,980 KB
testcase_11 AC 134 ms
40,304 KB
testcase_12 AC 136 ms
40,472 KB
testcase_13 AC 135 ms
39,644 KB
testcase_14 AC 133 ms
40,048 KB
testcase_15 AC 134 ms
41,900 KB
testcase_16 AC 135 ms
40,272 KB
testcase_17 AC 132 ms
39,968 KB
testcase_18 AC 133 ms
41,632 KB
testcase_19 AC 132 ms
39,896 KB
testcase_20 AC 133 ms
40,172 KB
testcase_21 AC 133 ms
41,992 KB
testcase_22 AC 135 ms
38,020 KB
testcase_23 AC 134 ms
40,184 KB
testcase_24 AC 127 ms
40,156 KB
testcase_25 AC 131 ms
40,008 KB
testcase_26 AC 133 ms
39,572 KB
testcase_27 AC 134 ms
38,332 KB
testcase_28 AC 132 ms
40,056 KB
testcase_29 AC 135 ms
42,404 KB
testcase_30 AC 135 ms
40,188 KB
testcase_31 AC 132 ms
40,108 KB
testcase_32 AC 134 ms
39,956 KB
testcase_33 AC 130 ms
40,332 KB
testcase_34 AC 132 ms
40,192 KB
testcase_35 AC 132 ms
39,976 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Microsoft (R) Visual C# Compiler version 3.9.0-6.21124.20 (db94f4cc)
Copyright (C) Microsoft Corporation. All rights reserved.

ソースコード

diff #

using System;
using System.Collections.Generic;
using System.Linq;
namespace Program {
    public class Solver {

        Random rnd = new Random();
        int n = 100;
        public void Solve() {
            int q = int.Parse(Console.ReadLine());
            //if (q != 450) throw new Exception();
            solve(0, n, new Stack<int>(Enumerate(n, x => x)));
            var ok = true;
            ok &= ans.Distinct().Count() == 100;
            ok &= ans.Min() == 0;
            ok &= ans.Max() == 99;
            if (!ok) throw new Exception();
            query(ans);

        }
        int[] ans = new int[100];
        void solve(int l, int r, Stack<int> a) {
            if (r - l == 1) { ans[l] = a.Pop(); return; }
            a = new Stack<int>(a.OrderBy(x => rnd.Next()));
            var L = new Stack<int>();
            var R = new Stack<int>();
            var m = (l + r) / 2;
            while (l + L.Count != m && m + R.Count != r) {
                var p = a.Pop();
                var q = a.Pop();
                var b = Enumerate(n, x => -1);
                for (int i = l; i < r; i++) b[i] = i < m ? p : q;
                var res = query(b);
                if (res[2] == 0 || res[2] == 2) {
                    if (res[2] == 0) Swap(ref p, ref q);
                    L.Push(p); R.Push(q);
                }
                else {
                    b = Enumerate(n, x => -1);
                    for (int i = l; i < m; i++) b[i] = p;
                    res = query(b);
                    if (res[2] == 1) { L.Push(p); L.Push(q); }
                    else { R.Push(p); R.Push(q); }
                }
            }
            while (l + L.Count != m) L.Push(a.Pop());
            while (m + R.Count != r) R.Push(a.Pop());
            solve(l, m, L);
            solve(m, r, R);

        }

        int[] query(int[] a) {
            for (int i = 0; i < a.Length; i++) {
                if (a[i] != -1) Console.Write($"{a[i] / 10}{a[i] % 10}");
                else Console.Write($"??");
                if (i + 1 != a.Length) Console.Write(" ");
                else Console.WriteLine();
            }
            Console.Out.Flush();
            return Console.ReadLine().Split().Select(int.Parse).ToArray();
        }
        static T[] Enumerate<T>(int n, Func<int, T> f) { var a = new T[n]; for (int i = 0; i < n; ++i) a[i] = f(i); return a; }
        static public void Swap<T>(ref T a, ref T b) { var tmp = a; a = b; b = tmp; }
    }
}

#region main
static class Ex {
    static public string AsString(this IEnumerable<char> ie) { return new string(ie.ToArray()); }
    static public string AsJoinedString<T>(this IEnumerable<T> ie, string st = " ") {
        return string.Join(st, ie.Select(x => x.ToString()).ToArray());
        //return string.Join(st, ie);
    }
    static public void Main() {
        Console.SetOut(new System.IO.StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false });
        var solver = new Program.Solver();
        solver.Solve();
        Console.Out.Flush();
    }
}
#endregion
0