結果

問題 No.305 鍵(2)
ユーザー te-sh
提出日時 2017-06-15 17:52:24
言語 D
(dmd 2.109.1)
結果
AC  
実行時間 27 ms / 2,000 ms
コード長 544 bytes
コンパイル時間 890 ms
コンパイル使用メモリ 99,460 KB
実行使用メモリ 25,220 KB
平均クエリ数 94.00
最終ジャッジ日時 2024-06-12 20:09:57
合計ジャッジ時間 2,438 ms
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 13
権限があれば一括ダウンロードができます

ソースコード

diff #

import std.algorithm, std.conv, std.range, std.stdio, std.string;

void main()
{
  auto r = new int[](10); r[] = -1;

  foreach (i; 0..10) {
    auto a = new int[](10);
    a[] = i;

    auto x = ask(a);
    if (x == 10) return;
    foreach (j; 0..10) {
      auto b = a.dup; b[j] = (b[j] + 1) % 10;
      auto y = ask(b);
      if (y == 10) return;
      if (y < x) r[j] = i;
    }
  }

  r.each!write; writeln; stdout.flush();
}

auto ask(int[] a)
{
  a.each!write; writeln; stdout.flush();
  auto rd = readln.split;
  return rd[0].to!int;
}
0