結果

問題 No.471 直列回転機
ユーザー te-shte-sh
提出日時 2017-12-11 12:23:46
言語 D
(dmd 2.106.1)
結果
AC  
実行時間 315 ms / 3,141 ms
コード長 1,391 bytes
コンパイル時間 804 ms
コンパイル使用メモリ 94,464 KB
実行使用メモリ 24,396 KB
平均クエリ数 19588.39
最終ジャッジ日時 2023-09-03 17:26:15
合計ジャッジ時間 16,120 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 25 ms
23,952 KB
testcase_01 AC 20 ms
24,000 KB
testcase_02 AC 21 ms
23,556 KB
testcase_03 AC 20 ms
24,348 KB
testcase_04 AC 20 ms
24,228 KB
testcase_05 AC 23 ms
23,508 KB
testcase_06 AC 21 ms
24,048 KB
testcase_07 AC 22 ms
24,036 KB
testcase_08 AC 41 ms
24,048 KB
testcase_09 AC 46 ms
23,244 KB
testcase_10 AC 30 ms
23,628 KB
testcase_11 AC 134 ms
24,216 KB
testcase_12 AC 246 ms
23,844 KB
testcase_13 AC 246 ms
24,396 KB
testcase_14 AC 285 ms
23,616 KB
testcase_15 AC 315 ms
24,336 KB
testcase_16 AC 23 ms
24,372 KB
testcase_17 AC 19 ms
24,024 KB
testcase_18 AC 19 ms
23,676 KB
testcase_19 AC 21 ms
23,364 KB
testcase_20 AC 310 ms
24,216 KB
testcase_21 AC 76 ms
23,388 KB
testcase_22 AC 271 ms
24,204 KB
testcase_23 AC 242 ms
23,556 KB
testcase_24 AC 165 ms
24,060 KB
testcase_25 AC 68 ms
23,388 KB
testcase_26 AC 287 ms
23,976 KB
testcase_27 AC 156 ms
23,400 KB
testcase_28 AC 172 ms
23,376 KB
testcase_29 AC 199 ms
23,544 KB
testcase_30 AC 94 ms
23,508 KB
testcase_31 AC 304 ms
23,640 KB
testcase_32 AC 253 ms
24,000 KB
testcase_33 AC 187 ms
23,808 KB
testcase_34 AC 285 ms
23,988 KB
testcase_35 AC 84 ms
23,556 KB
testcase_36 AC 128 ms
24,048 KB
testcase_37 AC 46 ms
23,988 KB
testcase_38 AC 67 ms
23,832 KB
testcase_39 AC 112 ms
23,388 KB
testcase_40 AC 210 ms
23,448 KB
testcase_41 AC 305 ms
23,976 KB
testcase_42 AC 200 ms
23,640 KB
testcase_43 AC 268 ms
23,508 KB
testcase_44 AC 52 ms
24,036 KB
testcase_45 AC 195 ms
23,796 KB
testcase_46 AC 222 ms
24,012 KB
testcase_47 AC 286 ms
23,544 KB
testcase_48 AC 233 ms
23,988 KB
testcase_49 AC 257 ms
23,652 KB
testcase_50 AC 301 ms
23,628 KB
testcase_51 AC 140 ms
24,312 KB
testcase_52 AC 29 ms
23,400 KB
testcase_53 AC 30 ms
23,628 KB
testcase_54 AC 29 ms
23,400 KB
testcase_55 AC 102 ms
23,628 KB
testcase_56 AC 88 ms
23,628 KB
testcase_57 AC 68 ms
23,832 KB
testcase_58 AC 39 ms
23,640 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

alias point = Point!int;

void main()
{
  auto m = readln.chomp.to!int;
  auto p = new point[](m);
  foreach (i; 0..m) {
    auto rd = readln.splitter;
    auto x = rd.front.to!int; rd.popFront();
    auto y = rd.front.to!int;
    p[i] = point(x, y);
  }

  auto q1 = ask(point(0, 0));
  auto q2 = ask(point(1, 0)) - q1;

  writeln("!");
  foreach (pi; p) {
    point r;
    if (q2.x == 1)
      r = point(pi.x, pi.y);
    else if (q2.x == -1)
      r = point(-pi.x, -pi.y);
    else if (q2.y == 1)
      r = point(-pi.y, pi.x);
    else if (q2.y == -1)
      r = point(pi.y, -pi.x);

    r = r + q1;

    writeln(r.x, " ", r.y);
  }
}

auto ask(point p)
{
  writeln("? ", p.x, " ", p.y); stdout.flush();
  auto rd = readln.split.to!(int[]), x = rd[0], y = rd[1];
  return point(x, y);
}

struct Point(T)
{
  T x, y;
  pure auto opBinary(string op: "+")(Point!T rhs) const { return Point!T(x + rhs.x, y + rhs.y); }
  pure auto opBinary(string op: "-")(Point!T rhs) const { return Point!T(x - rhs.x, y - rhs.y); }
  pure auto opBinary(string op: "*")(Point!T rhs) const { return x * rhs.x + y * rhs.y; }
  pure auto opBinary(string op: "*")(T a) const { return Point!T(x * a, y * a); }
  pure auto opBinary(string op: "/")(T a) const { return Point!T(x / a, y / a); }
  pure auto hypot2() const { return x ^^ 2 + y ^^ 2; }
}
0