結果
問題 | No.246 質問と回答 |
ユーザー | nokonoko |
提出日時 | 2015-07-18 14:53:17 |
言語 | C#(csc) (csc 3.9.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 3,318 bytes |
コンパイル時間 | 1,277 ms |
コンパイル使用メモリ | 116,756 KB |
実行使用メモリ | 44,344 KB |
平均クエリ数 | 31.70 |
最終ジャッジ日時 | 2024-07-16 07:13:28 |
合計ジャッジ時間 | 4,899 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 71 ms
39,568 KB |
testcase_01 | WA | - |
testcase_02 | WA | - |
testcase_03 | WA | - |
testcase_04 | WA | - |
testcase_05 | AC | 73 ms
43,540 KB |
testcase_06 | WA | - |
testcase_07 | AC | 79 ms
43,404 KB |
testcase_08 | AC | 77 ms
43,292 KB |
testcase_09 | WA | - |
testcase_10 | WA | - |
testcase_11 | AC | 71 ms
41,732 KB |
testcase_12 | AC | 72 ms
41,368 KB |
testcase_13 | WA | - |
testcase_14 | WA | - |
testcase_15 | AC | 72 ms
41,364 KB |
testcase_16 | WA | - |
testcase_17 | AC | 73 ms
41,732 KB |
testcase_18 | AC | 71 ms
41,476 KB |
testcase_19 | WA | - |
testcase_20 | WA | - |
testcase_21 | WA | - |
testcase_22 | AC | 71 ms
43,668 KB |
testcase_23 | AC | 77 ms
41,108 KB |
testcase_24 | WA | - |
testcase_25 | AC | 76 ms
43,144 KB |
testcase_26 | AC | 74 ms
43,648 KB |
testcase_27 | AC | 71 ms
39,600 KB |
testcase_28 | WA | - |
testcase_29 | WA | - |
コンパイルメッセージ
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.Linq; class Program { static void Main() { long answer = 500000000; long nowRange = answer / 2; long qCount = 100; while (nowRange > 0) { LIB.IO.W("? " + answer.ToString()); LIB.IO.WFLUSH(); if (LIB.IO.R<int>() == 1) { answer += nowRange; } else { answer -= nowRange; } nowRange >>= 1; qCount--; } int direction = 0; bool first = false; for (int i = 0; i < qCount; i++) { LIB.IO.W("? " + answer.ToString()); LIB.IO.WFLUSH(); int nowDirection = LIB.IO.R<int>(); if (first == false) { first = true; direction = nowDirection; } if (nowDirection == 1) { answer++; } else { answer--; } if (nowDirection != direction) { break; } } LIB.IO.W("! " + answer.ToString()); LIB.IO.WFLUSH(); } } namespace LIB { public class IO { private const int WMAX = 1000; private static string WSTRING = ""; public static T R<T>() { return (T)(Convert.ChangeType(R(), typeof(T))); } public static T[] R<T>(char splitter = ' ') { return R().Split(splitter).Select(v => UTILITY.PARSE<T>(v)).ToArray(); } public static T[] R<T>(int length) { T[] ret = new T[length]; for (int i = 0; i < length; i++) { ret[i] = R<T>(); } return ret; } public static T[][] R<T>(int length, char splitter = ' ') { T[][] ret = new T[length][]; for (int i = 0; i < length; i++) { ret[i] = R<T>(splitter); } return ret; } private static string R() { return Console.ReadLine(); } public static void W(object value, bool addLineFeed = true) { WSTRING += UTILITY.PARSE<string>(value); if (addLineFeed == true) { WSTRING += "\n"; } if (WSTRING.Count() >= WMAX) { WFLUSH(); } } public static void WFLUSH() { Console.Write(WSTRING); WSTRING = ""; } } public class UTILITY { public static T PARSE<T>(object value) { return (T)(Convert.ChangeType(value, typeof(T))); } } public class MEMO<Key, Result> { private Dictionary<Key, Result> results; public MEMO() { results = new Dictionary<Key, Result>(); } public Result EXEC(Key key, Func<Key, Result> func) { Result ret = default(Result); if (results.ContainsKey(key)) { ret = results[key]; } else { ret = func(key); results.Add(key, ret); } return ret; } } }