Submission #57315658


Source Code Expand

Copy
H, W, N = gets.split.map(&:to_i)
S = N.times.map{ gets.split.map(&:to_i) << _1 }
C = S.sort
x = []
y = []
prev = Array.new(N)
C.each do |r,c,i|
j = x.bsearch_index{|x| x > c } || x.size
x[j] = c
y[j] = i
prev[i] = y[j - 1] if j > 0
end
z = y[-1]
ans = []
rz, cz, _ = S[z]
ans << ('D' * (H - rz)) << ('R' * (W - cz))
until z.nil?
 
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
H, W, N = gets.split.map(&:to_i)
S = N.times.map{ gets.split.map(&:to_i) << _1 }
C = S.sort

x = []
y = []
prev = Array.new(N)
C.each do |r,c,i|
  j = x.bsearch_index{|x| x > c } || x.size
  x[j] = c
  y[j] = i
  prev[i] = y[j - 1] if j > 0
end

z = y[-1]

ans = []
rz, cz, _ = S[z]
ans << ('D' * (H - rz)) << ('R' * (W - cz))

until z.nil?
  rz, cz, _ = S[z]
  if w = prev[z]
    rw, cw, _ = S[w]
    ans << ('D' * (rz - rw)) << ('R' * (cz - cw))
  else
    ans << ('D' * (rz - 1)) << ('R' * (cz - 1))
  end
  z = prev[z]
end
puts x.size
puts ans.join.reverse

Submission Info

Submission Time
Task F - Gather Coins
User tinsep19
Language Ruby (ruby 3.2.2)
Score 500
Code Size 560 Byte
Status AC
Exec Time 1180 ms
Memory 65104 KB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 500 / 500
Status
AC × 3
AC × 44
Set Name Test Cases
Sample 00_sample_00.txt, 00_sample_01.txt, 00_sample_02.txt
All 00_sample_00.txt, 00_sample_01.txt, 00_sample_02.txt, 01_random_00.txt, 01_random_01.txt, 01_random_02.txt, 01_random_03.txt, 01_random_04.txt, 01_random_05.txt, 01_random_06.txt, 01_random_07.txt, 01_random_08.txt, 01_random_09.txt, 02_random2_00.txt, 02_random2_01.txt, 02_random2_02.txt, 02_random2_03.txt, 02_random2_04.txt, 02_random2_05.txt, 02_random2_06.txt, 02_random2_07.txt, 02_random2_08.txt, 02_random2_09.txt, 03_random3_00.txt, 03_random3_01.txt, 03_random3_02.txt, 03_random3_03.txt, 03_random3_04.txt, 03_random3_05.txt, 03_random3_06.txt, 03_random3_07.txt, 03_random3_08.txt, 03_random3_09.txt, 04_full_00.txt, 04_full_01.txt, 04_full_02.txt, 05_handmade_00.txt, 05_handmade_01.txt, 05_handmade_02.txt, 05_handmade_03.txt, 05_handmade_04.txt, 05_handmade_05.txt, 05_handmade_06.txt, 05_handmade_07.txt
Case Name Status Exec Time Memory
00_sample_00.txt AC 47 ms 17148 KB
00_sample_01.txt AC 51 ms 17136 KB
00_sample_02.txt AC 51 ms 17184 KB
01_random_00.txt AC 890 ms 33240 KB
01_random_01.txt AC 857 ms 32988 KB
01_random_02.txt AC 743 ms 32908 KB
01_random_03.txt AC 451 ms 25520 KB
01_random_04.txt AC 140 ms 19760 KB
01_random_05.txt AC 886 ms 33760 KB
01_random_06.txt AC 876 ms 33968 KB
01_random_07.txt AC 906 ms 33828 KB
01_random_08.txt AC 911 ms 33812 KB
01_random_09.txt AC 880 ms 33700 KB
02_random2_00.txt AC 1065 ms 63840 KB
02_random2_01.txt AC 1068 ms 55356 KB
02_random2_02.txt AC 1006 ms 50416 KB
02_random2_03.txt AC 1002 ms 50444 KB
02_random2_04.txt AC 985 ms 45936 KB
02_random2_05.txt AC 1013 ms 43000 KB
02_random2_06.txt AC 1002 ms 41812 KB
02_random2_07.txt AC 952 ms 40820 KB
02_random2_08.txt AC 968 ms 38500 KB
02_random2_09.txt AC 939 ms 37312 KB
03_random3_00.txt AC 829 ms 33688 KB
03_random3_01.txt AC 865 ms 33736 KB
03_random3_02.txt AC 858 ms 33612 KB
03_random3_03.txt AC 866 ms 33644 KB
03_random3_04.txt AC 857 ms 33584 KB
03_random3_05.txt AC 860 ms 33664 KB
03_random3_06.txt AC 866 ms 33864 KB
03_random3_07.txt AC 860 ms 33652 KB
03_random3_08.txt AC 848 ms 33544 KB
03_random3_09.txt AC 866 ms 33652 KB
04_full_00.txt AC 162 ms 20300 KB
04_full_01.txt AC 577 ms 27844 KB
04_full_02.txt AC 297 ms 22168 KB
05_handmade_00.txt AC 1103 ms 62820 KB
05_handmade_01.txt AC 1104 ms 61156 KB
05_handmade_02.txt AC 829 ms 33632 KB
05_handmade_03.txt AC 1167 ms 65104 KB
05_handmade_04.txt AC 1180 ms 63976 KB
05_handmade_05.txt AC 1061 ms 50500 KB
05_handmade_06.txt AC 984 ms 51368 KB
05_handmade_07.txt AC 47 ms 18188 KB


2025-04-21 (Mon)
21:49:15 +00:00