結果

問題 No.355 数当てゲーム(2)
ユーザー te-shte-sh
提出日時 2017-07-11 14:09:03
言語 D
(dmd 2.106.1)
結果
AC  
実行時間 29 ms / 2,000 ms
コード長 955 bytes
コンパイル時間 697 ms
コンパイル使用メモリ 102,668 KB
実行使用メモリ 24,468 KB
平均クエリ数 20.67
最終ジャッジ日時 2023-09-03 15:08:31
合計ジャッジ時間 5,839 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 29 ms
24,000 KB
testcase_01 AC 27 ms
24,012 KB
testcase_02 AC 26 ms
23,388 KB
testcase_03 AC 27 ms
23,616 KB
testcase_04 AC 26 ms
23,400 KB
testcase_05 AC 26 ms
23,424 KB
testcase_06 AC 26 ms
24,012 KB
testcase_07 AC 26 ms
23,388 KB
testcase_08 AC 26 ms
23,976 KB
testcase_09 AC 26 ms
24,228 KB
testcase_10 AC 26 ms
23,628 KB
testcase_11 AC 26 ms
23,988 KB
testcase_12 AC 26 ms
23,616 KB
testcase_13 AC 28 ms
23,436 KB
testcase_14 AC 26 ms
23,508 KB
testcase_15 AC 26 ms
23,400 KB
testcase_16 AC 26 ms
24,468 KB
testcase_17 AC 26 ms
23,424 KB
testcase_18 AC 26 ms
23,388 KB
testcase_19 AC 27 ms
23,652 KB
testcase_20 AC 26 ms
24,264 KB
testcase_21 AC 27 ms
23,652 KB
testcase_22 AC 27 ms
23,640 KB
testcase_23 AC 26 ms
23,604 KB
testcase_24 AC 26 ms
24,048 KB
testcase_25 AC 27 ms
23,388 KB
testcase_26 AC 26 ms
23,628 KB
testcase_27 AC 26 ms
24,048 KB
testcase_28 AC 26 ms
23,628 KB
testcase_29 AC 26 ms
23,388 KB
testcase_30 AC 29 ms
23,556 KB
testcase_31 AC 26 ms
23,424 KB
testcase_32 AC 27 ms
24,336 KB
testcase_33 AC 27 ms
23,388 KB
testcase_34 AC 27 ms
23,352 KB
testcase_35 AC 26 ms
24,324 KB
testcase_36 AC 27 ms
23,388 KB
testcase_37 AC 27 ms
23,616 KB
testcase_38 AC 27 ms
24,228 KB
testcase_39 AC 27 ms
23,640 KB
testcase_40 AC 27 ms
23,556 KB
testcase_41 AC 27 ms
23,544 KB
testcase_42 AC 26 ms
24,024 KB
testcase_43 AC 26 ms
23,808 KB
testcase_44 AC 26 ms
24,300 KB
testcase_45 AC 26 ms
24,000 KB
testcase_46 AC 25 ms
24,288 KB
testcase_47 AC 26 ms
23,796 KB
testcase_48 AC 27 ms
23,388 KB
testcase_49 AC 25 ms
24,300 KB
testcase_50 AC 27 ms
23,616 KB
testcase_51 AC 27 ms
23,388 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

struct Res { int x, y; }

void main()
{
  auto d = new bool[](10);
  auto s = new int[](10);

  foreach (i; 3..10) {
    auto r = ask([0,1,2,i]);
    s[i] = r.x + r.y;
  }

  auto rm1 = s[3..10].maxElement;
  foreach (i; 3..10)
    if (s[i] == rm1)
      d[i] = true;

  if (d[3..10].count(true) == 1)
    d[0..3][] = true;

  if (d.count(true) < 4) {
    foreach (i; 0..3) {
      auto r = ask([3,4,5,i]);
      s[i] = r.x + r.y;
    }
    auto rm2 = s[0..3].maxElement;
    foreach (i; 0..3)
      if (s[i] == rm2)
        d[i] = true;
  }

  auto t = d.enumerate.filter!"a[1]".map!"a[0]".array.to!(int[]);

  do {
    ask(t);
  } while (t.nextPermutation);
}

auto ask(int[] n)
{
  import core.stdc.stdlib;
  writeln(n.to!(string[]).join(" "));
  stdout.flush();
  auto rd = readln.split.to!(int[]), x = rd[0], y = rd[1];
  if (x == 4 && y == 0) exit(0);
  return Res(rd[0], rd[1]);
}
0