結果
| 問題 |
No.594 壊れた宝物発見機
|
| コンテスト | |
| ユーザー |
phage64
|
| 提出日時 | 2017-11-18 18:46:52 |
| 言語 | C#(csc) (csc 3.9.0) |
| 結果 |
AC
|
| 実行時間 | 132 ms / 2,000 ms |
| コード長 | 2,033 bytes |
| コンパイル時間 | 854 ms |
| コンパイル使用メモリ | 115,672 KB |
| 実行使用メモリ | 42,632 KB |
| 平均クエリ数 | 46.60 |
| 最終ジャッジ日時 | 2024-07-16 14:51:01 |
| 合計ジャッジ時間 | 4,624 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 20 |
コンパイルメッセージ
Microsoft (R) Visual C# Compiler version 3.9.0-6.21124.20 (db94f4cc) Copyright (C) Microsoft Corporation. All rights reserved.
ソースコード
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
phage64