結果

問題 No.675 ドットちゃんたち
ユーザー yuruhiya
提出日時 2021-01-24 10:32:03
言語 Crystal
(1.14.0)
結果
AC  
実行時間 84 ms / 2,000 ms
コード長 589 bytes
コンパイル時間 11,172 ms
コンパイル使用メモリ 296,348 KB
実行使用メモリ 27,064 KB
最終ジャッジ日時 2024-06-30 22:09:28
合計ジャッジ時間 12,869 ms
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 8
権限があれば一括ダウンロードができます

ソースコード

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