結果

問題 No.594 壊れた宝物発見機
ユーザー phage64phage64
提出日時 2017-11-18 18:44:29
言語 C#(csc)
(csc 3.9.0)
結果
WA  
実行時間 -
コード長 2,080 bytes
コンパイル時間 3,179 ms
コンパイル使用メモリ 108,176 KB
実行使用メモリ 41,128 KB
平均クエリ数 68.80
最終ジャッジ日時 2023-09-23 15:06:50
合計ジャッジ時間 8,874 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
権限があれば一括ダウンロードができます
コンパイルメッセージ
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;

                pr.WriteLine($"{min} {max}");
            }
            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