Contest Duration: - (local time) (100 minutes) Back to Home

Submission #6610224

Source Code Expand

Copy
```K = gets.not_nil!.to_i
x, y = gets.not_nil!.split.map(&.to_i)

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

ans = [] of Array(Int32)

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

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

while cx != x || cy != y
dx = x - cx
dy = y - cy

if dx + dy == K
ans << [x, y]
elsif (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]
elsif dx + dy >= K
a = [dy, K].min
b = [dx, K - a].min
cy += a
cx += b
ans << [cx, cy]
else
cx -= K
ans << [cx, cy]
end
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 2019-07-30 05:09:56+0900 E - Golf pekempey Crystal (0.20.5) 0 1032 Byte TLE 2119 ms 741116 KB

#### Judge Result

Score / Max Score 0 / 0 0 / 500
Status
 AC × 3
 AC × 54 TLE × 1
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 AC 2 ms 636 KB
sample_02.txt AC 2 ms 636 KB
sample_03.txt AC 2 ms 636 KB
sub1_01.txt AC 2 ms 636 KB
sub1_02.txt AC 2 ms 636 KB
sub1_03.txt AC 2 ms 636 KB
sub1_04.txt AC 2 ms 636 KB
sub1_05.txt AC 2 ms 636 KB
sub1_06.txt AC 2 ms 2556 KB
sub1_07.txt AC 2 ms 636 KB
sub1_08.txt AC 2 ms 636 KB
sub1_09.txt AC 2 ms 636 KB
sub1_10.txt AC 2 ms 636 KB
sub1_11.txt AC 2 ms 636 KB
sub1_12.txt AC 2 ms 636 KB
sub1_13.txt AC 2 ms 636 KB
sub1_14.txt AC 2 ms 636 KB
sub1_15.txt AC 2 ms 636 KB
sub1_16.txt AC 7 ms 1020 KB
sub1_17.txt AC 2 ms 636 KB
sub1_18.txt AC 2 ms 636 KB
sub1_19.txt AC 2 ms 636 KB
sub1_20.txt AC 29 ms 2172 KB
sub1_21.txt AC 2 ms 636 KB
sub1_22.txt AC 2 ms 636 KB
sub1_23.txt AC 2 ms 636 KB
sub1_24.txt AC 7 ms 1020 KB
sub1_25.txt TLE 2119 ms 741116 KB
sub1_26.txt AC 2 ms 636 KB
sub1_27.txt AC 2 ms 636 KB
sub1_28.txt AC 13 ms 1276 KB
sub1_29.txt AC 2 ms 2556 KB
sub1_30.txt AC 2 ms 636 KB
sub1_31.txt AC 2 ms 636 KB
sub1_32.txt AC 2 ms 636 KB
sub1_33.txt AC 13 ms 1276 KB
sub1_34.txt AC 642 ms 39292 KB
sub1_35.txt AC 2 ms 636 KB
sub1_36.txt AC 2 ms 636 KB
sub1_37.txt AC 2 ms 636 KB
sub1_38.txt AC 2 ms 2556 KB
sub1_39.txt AC 11 ms 1276 KB
sub1_40.txt AC 2 ms 636 KB
sub1_41.txt AC 2 ms 636 KB
sub1_42.txt AC 2 ms 636 KB
sub1_43.txt AC 2 ms 636 KB
sub1_44.txt AC 2 ms 636 KB
sub1_45.txt AC 2 ms 636 KB
sub1_46.txt AC 5 ms 892 KB
sub1_47.txt AC 217 ms 10748 KB
sub1_48.txt AC 2 ms 636 KB
sub1_49.txt AC 2 ms 636 KB
sub1_50.txt AC 2 ms 636 KB
sub1_51.txt AC 224 ms 10364 KB
sub1_52.txt AC 2 ms 636 KB