結果

問題 No.594 壊れた宝物発見機
ユーザー phage64phage64
提出日時 2017-11-18 18:46:52
言語 C#(csc)
(csc 3.9.0)
結果
AC  
実行時間 169 ms / 2,000 ms
コード長 2,033 bytes
コンパイル時間 3,199 ms
コンパイル使用メモリ 104,944 KB
実行使用メモリ 38,872 KB
平均クエリ数 46.60
最終ジャッジ日時 2023-09-23 15:06:58
合計ジャッジ時間 7,956 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 166 ms
38,432 KB
testcase_01 AC 166 ms
38,872 KB
testcase_02 AC 169 ms
38,512 KB
testcase_03 AC 163 ms
38,492 KB
testcase_04 AC 161 ms
34,508 KB
testcase_05 AC 162 ms
38,644 KB
testcase_06 AC 162 ms
36,776 KB
testcase_07 AC 161 ms
34,964 KB
testcase_08 AC 164 ms
36,540 KB
testcase_09 AC 162 ms
37,168 KB
testcase_10 AC 162 ms
36,628 KB
testcase_11 AC 167 ms
36,756 KB
testcase_12 AC 167 ms
38,696 KB
testcase_13 AC 165 ms
37,196 KB
testcase_14 AC 166 ms
37,036 KB
testcase_15 AC 163 ms
36,928 KB
testcase_16 AC 166 ms
38,532 KB
testcase_17 AC 169 ms
37,112 KB
testcase_18 AC 166 ms
36,364 KB
testcase_19 AC 160 ms
35,084 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.IO;

class Program
{
    static void Solve()
    {
        int[] pos = { 0, 0, 0 };

        for (var i = 0; i < 3; i++)
        {
            int min = -100, max = 101;
            while (min + 1 < max)
            {
                int m = (max - min) / 2 + min;
                pos[i] = m - 1;
                int n1 = Ask(pos);
                pos[i] = m;
                int n2 = Ask(pos);

                if (n1 < n2)
                    max = m;
                else
                    min = m;
            }
            pos[i] = min;
        }

        Ans(pos);
    }

    static int Ask(int[] pos)
    {
        pr.WriteLine($"? {pos[0]} {pos[1]} {pos[2]}");
        return sc.Int();
    }

    static void Ans(int[] pos)
    {
        pr.WriteLine($"! {pos[0]} {pos[1]} {pos[2]}");
    }

    static void Main(string[] args)
    {
        pr.AutoFlush = true;
        Solve();
        pr.Flush();
    }

    static Scanner sc = new Scanner();
    static Printer pr = new Printer();
    static readonly int MOD = 1000000007;
}

#region IO
class Scanner
{
    private int _i = 0; 
    private string[] line = new string[0];

    private T[] Enumerate<T>(int n, Func<T> f)
    {
        T[] ret = new T[n];
        for (int i = 0; i < n; i++)
            ret[i] = f();
        return ret;
    }

    public string String()
    {
        if (line.Length <= _i)
        {
            line = Console.ReadLine().Split(' ');
            _i = 0;
        }

        return line[_i++];
    }

    public int Int() => int.Parse(String());
    public long Long() => long.Parse(String());
    public double Double() => double.Parse(String());
    public int[] Int(int n) => Enumerate(n, Int);
    public long[] Long(int n) => Enumerate(n, Long);
    public double[] Double(int n) => Enumerate(n, Double);
    public string[] String(int n) => Enumerate(n, String);
}

class Printer : StreamWriter
{
    public Printer() : base(Console.OpenStandardOutput())
    {
        AutoFlush = false;
    }
}
#endregion
0