Submission #6610167


Source Code Expand

Copy
K = gets.to_i
x, y = gets.split.map(&:to_i)

sx, sy = 1, 1
if x < 0 then sx = -1; x *= -1 end
if y < 0 then sy = -1; y *= -1 end
sz = false
if x < y
  sz = true
  x, y = y, x
end

ans = []

if K.even? && (x + y) % 2 == 1
  puts -1
  exit
end

cx, cy = 0, 0
while ((x - cx).abs + (y - cy).abs) > 2*K
  dy = [(y - cy).abs, K].min
  dx = [(x - cx).abs, K - dy].min
  cx += dx
  cy += dy
  ans << [cx, cy]
end

dx = x - cx
dy = y - cy

if dx + dy == K
  ans << [x, y]
elsif (K + dx + dy) % 2 == 0
  a = (2*K - dx - dy) / 2
  b = K - a
  c = dx - K + a
  d = K - c
  cy -= a
  cx += b
  ans << [cx, cy]
  cx += c
  cy += d
  ans << [cx, cy]
else
  a = (K - dx - dy) / 2
  b = K - a
  c = dx + a
  d = K - c
  cy -= a
  cx += b
  ans << [cx, cy]
  cx += c
  cy += d
  ans << [cx, cy]
  cx -= K
  ans << [cx, cy]
end

puts ans.size
ans.each do |e|
  if sz
    e[0], e[1] = e[1], e[0]
  end
  puts "#{e[0]*sx} #{e[1]*sy}"
end

Submission Info

Submission Time
Task E - Golf
User pekempey
Language Ruby (2.3.3)
Score 0
Code Size 982 Byte
Status WA
Exec Time 420 ms
Memory 18300 KB

Compile Error

./Main.rb:16: warning: ambiguous first argument; put parentheses or a space even after `-' operator

Judge Result

Set Name Sample Subtask1
Score / Max Score 0 / 0 0 / 500
Status
AC × 2
WA × 1
AC × 19
WA × 36
Set Name Test Cases
Sample sample_01.txt, sample_02.txt, sample_03.txt
Subtask1 sample_01.txt, sample_02.txt, sample_03.txt, sub1_01.txt, sub1_02.txt, sub1_03.txt, sub1_04.txt, sub1_05.txt, sub1_06.txt, sub1_07.txt, sub1_08.txt, sub1_09.txt, sub1_10.txt, sub1_11.txt, sub1_12.txt, sub1_13.txt, sub1_14.txt, sub1_15.txt, sub1_16.txt, sub1_17.txt, sub1_18.txt, sub1_19.txt, sub1_20.txt, sub1_21.txt, sub1_22.txt, sub1_23.txt, sub1_24.txt, sub1_25.txt, sub1_26.txt, sub1_27.txt, sub1_28.txt, sub1_29.txt, sub1_30.txt, sub1_31.txt, sub1_32.txt, sub1_33.txt, sub1_34.txt, sub1_35.txt, sub1_36.txt, sub1_37.txt, sub1_38.txt, sub1_39.txt, sub1_40.txt, sub1_41.txt, sub1_42.txt, sub1_43.txt, sub1_44.txt, sub1_45.txt, sub1_46.txt, sub1_47.txt, sub1_48.txt, sub1_49.txt, sub1_50.txt, sub1_51.txt, sub1_52.txt
Case Name Status Exec Time Memory
sample_01.txt WA 7 ms 1788 KB
sample_02.txt AC 7 ms 1788 KB
sample_03.txt AC 7 ms 1788 KB
sub1_01.txt WA 7 ms 1788 KB
sub1_02.txt AC 7 ms 1788 KB
sub1_03.txt AC 7 ms 1788 KB
sub1_04.txt AC 7 ms 1788 KB
sub1_05.txt WA 7 ms 1788 KB
sub1_06.txt WA 7 ms 1788 KB
sub1_07.txt WA 7 ms 1788 KB
sub1_08.txt AC 7 ms 1788 KB
sub1_09.txt WA 7 ms 1788 KB
sub1_10.txt AC 7 ms 1788 KB
sub1_11.txt AC 7 ms 1788 KB
sub1_12.txt AC 7 ms 1788 KB
sub1_13.txt WA 7 ms 1788 KB
sub1_14.txt WA 7 ms 1788 KB
sub1_15.txt WA 7 ms 1788 KB
sub1_16.txt AC 11 ms 2172 KB
sub1_17.txt AC 7 ms 1788 KB
sub1_18.txt WA 7 ms 1788 KB
sub1_19.txt WA 7 ms 1788 KB
sub1_20.txt AC 26 ms 2812 KB
sub1_21.txt WA 7 ms 1788 KB
sub1_22.txt WA 7 ms 1788 KB
sub1_23.txt WA 7 ms 1788 KB
sub1_24.txt AC 11 ms 2172 KB
sub1_25.txt AC 7 ms 1788 KB
sub1_26.txt WA 7 ms 1788 KB
sub1_27.txt WA 7 ms 1788 KB
sub1_28.txt AC 15 ms 2172 KB
sub1_29.txt WA 7 ms 1788 KB
sub1_30.txt WA 7 ms 1788 KB
sub1_31.txt WA 7 ms 1788 KB
sub1_32.txt AC 7 ms 1788 KB
sub1_33.txt AC 15 ms 2172 KB
sub1_34.txt WA 420 ms 18300 KB
sub1_35.txt WA 7 ms 1788 KB
sub1_36.txt WA 7 ms 1788 KB
sub1_37.txt AC 7 ms 1788 KB
sub1_38.txt WA 7 ms 1788 KB
sub1_39.txt WA 14 ms 2172 KB
sub1_40.txt WA 7 ms 1788 KB
sub1_41.txt WA 7 ms 1788 KB
sub1_42.txt WA 7 ms 1788 KB
sub1_43.txt WA 7 ms 1788 KB
sub1_44.txt WA 7 ms 1788 KB
sub1_45.txt WA 7 ms 1788 KB
sub1_46.txt WA 10 ms 2044 KB
sub1_47.txt WA 150 ms 9980 KB
sub1_48.txt WA 7 ms 1788 KB
sub1_49.txt WA 7 ms 1788 KB
sub1_50.txt WA 7 ms 1788 KB
sub1_51.txt WA 156 ms 9980 KB
sub1_52.txt AC 7 ms 1788 KB