AtCoder Beginner Contest 035

Submission #732244

Source codeソースコード

s = STDIN.gets
t = STDIN.gets

class Drone
  def self.exec(s, t)
    x = y = hatena = 0
    s.split(//).each do |c|
      case c
      when 'L' then x -= 1
      when 'R' then x += 1
      when 'U' then y += 1
      when 'D' then y -= 1
      when '?' then hatena += 1
      end
    end

    distance = x.abs + y.abs

    if t.to_i == 1
      distance + hatena
    else
      if distance >= hatena
        distance - hatena
      else
        if (distance - hatena) % 2 == 0
          0
        else
          1
        end
      end
    end
  end
end

puts Drone.exec(s, t)

Submission

Task問題 B - ドローン
User nameユーザ名 buty4649
Created time投稿日時
Language言語 Ruby (2.3.3)
Status状態 AC
Score得点 101
Source lengthソースコード長 608 Byte
File nameファイル名
Exec time実行時間 163 ms
Memory usageメモリ使用量 6780 KB

Test case

Set

Set name Score得点 / Max score Cases
Sample - 00_example_01.txt,00_example_02.txt,00_example_03.txt,00_example_04.txt
Subtask1 100 / 100 00_example_01.txt,00_example_02.txt,00_example_03.txt,10_rand_01.txt,10_rand_02.txt,10_rand_03.txt,10_rand_04.txt,20_no_question_01.txt,20_no_question_02.txt,20_no_question_03.txt,20_no_question_04.txt,30_max_01.txt,30_max_02.txt,30_max_03.txt,30_max_04.txt,40_corner_01.txt,40_corner_02.txt,40_corner_03.txt,40_corner_04.txt
All 1 / 1 00_example_01.txt,00_example_02.txt,00_example_03.txt,00_example_04.txt,10_rand_01.txt,10_rand_02.txt,10_rand_03.txt,10_rand_04.txt,20_no_question_01.txt,20_no_question_02.txt,20_no_question_03.txt,20_no_question_04.txt,30_max_01.txt,30_max_02.txt,30_max_03.txt,30_max_04.txt,40_corner_01.txt,40_corner_02.txt,40_corner_03.txt,40_corner_04.txt,50_hand_01.txt,50_hand_02.txt,50_hand_03.txt,60_rand_01.txt,60_rand_02.txt,60_rand_03.txt,60_rand_04.txt,70_no_ques_01.txt,70_no_ques_02.txt,70_no_ques_03.txt,70_no_ques_04.txt,80_max_01.txt,80_max_02.txt,80_max_03.txt,80_max_04.txt,90_corner_01.txt,90_corner_02.txt,90_corner_03.txt,90_corner_04.txt

Test case

Case name Status状態 Exec time実行時間 Memory usageメモリ使用量
00_example_01.txt AC 17 ms 1788 KB
00_example_02.txt AC 17 ms 1788 KB
00_example_03.txt AC 17 ms 1788 KB
00_example_04.txt AC 17 ms 1788 KB
10_rand_01.txt AC 39 ms 2556 KB
10_rand_02.txt AC 18 ms 1788 KB
10_rand_03.txt AC 23 ms 1916 KB
10_rand_04.txt AC 24 ms 1916 KB
20_no_question_01.txt AC 39 ms 2556 KB
20_no_question_02.txt AC 18 ms 1788 KB
20_no_question_03.txt AC 23 ms 1916 KB
20_no_question_04.txt AC 24 ms 1916 KB
30_max_01.txt AC 138 ms 6780 KB
30_max_02.txt AC 138 ms 6780 KB
30_max_03.txt AC 138 ms 6780 KB
30_max_04.txt AC 137 ms 6780 KB
40_corner_01.txt AC 136 ms 6780 KB
40_corner_02.txt AC 134 ms 6780 KB
40_corner_03.txt AC 134 ms 6780 KB
40_corner_04.txt AC 137 ms 6780 KB
50_hand_01.txt AC 18 ms 1788 KB
50_hand_02.txt AC 18 ms 1788 KB
50_hand_03.txt AC 17 ms 1788 KB
60_rand_01.txt AC 39 ms 2556 KB
60_rand_02.txt AC 18 ms 1788 KB
60_rand_03.txt AC 22 ms 1916 KB
60_rand_04.txt AC 25 ms 1916 KB
70_no_ques_01.txt AC 39 ms 2556 KB
70_no_ques_02.txt AC 18 ms 1788 KB
70_no_ques_03.txt AC 22 ms 1916 KB
70_no_ques_04.txt AC 24 ms 1916 KB
80_max_01.txt AC 139 ms 6780 KB
80_max_02.txt AC 137 ms 6780 KB
80_max_03.txt AC 163 ms 6780 KB
80_max_04.txt AC 138 ms 6780 KB
90_corner_01.txt AC 136 ms 6780 KB
90_corner_02.txt AC 135 ms 6780 KB
90_corner_03.txt AC 137 ms 6780 KB
90_corner_04.txt AC 138 ms 6780 KB