結果

問題 No.675 ドットちゃんたち
ユーザー yuruhiyayuruhiya
提出日時 2021-01-24 10:32:03
言語 Crystal
(1.11.2)
結果
AC  
実行時間 84 ms / 2,000 ms
コード長 589 bytes
コンパイル時間 17,184 ms
コンパイル使用メモリ 257,064 KB
実行使用メモリ 32,100 KB
最終ジャッジ日時 2023-09-13 13:17:20
合計ジャッジ時間 19,227 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,452 KB
testcase_01 AC 3 ms
4,380 KB
testcase_02 AC 2 ms
4,436 KB
testcase_03 AC 2 ms
4,420 KB
testcase_04 AC 3 ms
4,384 KB
testcase_05 AC 55 ms
23,124 KB
testcase_06 AC 84 ms
32,100 KB
testcase_07 AC 66 ms
21,652 KB
testcase_08 AC 67 ms
22,044 KB
testcase_09 AC 76 ms
22,880 KB
testcase_10 AC 77 ms
28,092 KB
testcase_11 AC 77 ms
28,644 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

lib C
  fun strtoll(s : UInt8*, p : UInt8**, b : Int32) : Int64
end

class String
  def to_i64
    C.strtoll(self, nil, 10)
  end
end

n, px, py = read_line.split.map(&.to_i64)
com = (1..n).map { read_line.split.map(&.to_i64) }

x1, x2, y1, y2, s = 1i64, 0i64, 1i64, 0i64, false
ans = com.reverse.map do |a|
  case a[0]
  when 1
    x2 -= a[1]
  when 2
    y2 -= a[1]
  when 3
    y1 *= -1
    y2 *= -1
    x1, y1 = y1, x1
    x2, y2 = y2, x2
    s = !s
  end
  x, y = px, py
  x = (x - x2) * x1
  y = (y - y2) * y1
  x, y = y, x if s
  {x, y}
end
puts ans.reverse.join('\n', &.join(' '))
0