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

Submission #6610204

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

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
s = ""
ans.each do |e|
if sz
e[0], e[1] = e[1], e[0]
end
s += "#{e[0]*sx} #{e[1]*sy}\n"
end
puts s```

#### Submission Info

Submission Time 2019-07-30 04:57:58+0900 E - Golf pekempey Ruby (2.3.3) 0 1035 Byte TLE 2130 ms 381436 KB

#### Compile Error

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

#### Judge Result

Score / Max Score 0 / 0 0 / 500
Status
 AC × 3
 AC × 51 TLE × 4
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 7 ms 1788 KB
sample_02.txt AC 7 ms 1788 KB
sample_03.txt AC 7 ms 1788 KB
sub1_01.txt AC 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 AC 7 ms 3836 KB
sub1_06.txt AC 7 ms 1788 KB
sub1_07.txt AC 7 ms 1788 KB
sub1_08.txt AC 7 ms 1788 KB
sub1_09.txt AC 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 AC 7 ms 1788 KB
sub1_14.txt AC 7 ms 1788 KB
sub1_15.txt AC 7 ms 1788 KB
sub1_16.txt AC 15 ms 9852 KB
sub1_17.txt AC 7 ms 1788 KB
sub1_18.txt AC 7 ms 1788 KB
sub1_19.txt AC 7 ms 1788 KB
sub1_20.txt AC 103 ms 69564 KB
sub1_21.txt AC 7 ms 1788 KB
sub1_22.txt AC 7 ms 1788 KB
sub1_23.txt AC 7 ms 1788 KB
sub1_24.txt AC 17 ms 12540 KB
sub1_25.txt TLE 2130 ms 381436 KB
sub1_26.txt AC 7 ms 1788 KB
sub1_27.txt AC 7 ms 1788 KB
sub1_28.txt AC 37 ms 41084 KB
sub1_29.txt AC 7 ms 1788 KB
sub1_30.txt AC 7 ms 1788 KB
sub1_31.txt AC 7 ms 1788 KB
sub1_32.txt AC 7 ms 1788 KB
sub1_33.txt AC 35 ms 40060 KB
sub1_34.txt TLE 2114 ms 169912 KB
sub1_35.txt AC 7 ms 1788 KB
sub1_36.txt AC 7 ms 1788 KB
sub1_37.txt AC 7 ms 1788 KB
sub1_38.txt AC 7 ms 1788 KB
sub1_39.txt AC 26 ms 22268 KB
sub1_40.txt AC 7 ms 1788 KB
sub1_41.txt AC 7 ms 1788 KB
sub1_42.txt AC 7 ms 1788 KB
sub1_43.txt AC 7 ms 1788 KB
sub1_44.txt AC 7 ms 1788 KB
sub1_45.txt AC 7 ms 1788 KB
sub1_46.txt AC 13 ms 8188 KB
sub1_47.txt TLE 2112 ms 91196 KB
sub1_48.txt AC 7 ms 1788 KB
sub1_49.txt AC 7 ms 1788 KB
sub1_50.txt AC 7 ms 1788 KB
sub1_51.txt TLE 2112 ms 93892 KB
sub1_52.txt AC 7 ms 1788 KB