Submission #1117525


Source Code Expand

def solve()
    n = gets.to_i
    answers = gets.chomp.chars.map{|token| token == "o"}
    animals = Array.new(n)

    [true, false].repeated_permutation(2) do |head, tail|
        animals[0] = head
        animals[-1] = tail

        (0...n).each{|i| animals[i + 1] = animals[i] == answers[i] ? animals[i - 1] : !animals[i - 1]}
        return animals[0...-1].map{|animal| animal ? "S" : "W"}.join if animals[0] == animals[-1]
    end

    -1
end

puts solve()

Submission Info

Submission Time
Task D - Menagerie
User nekoTheShadow
Language Ruby (2.3.3)
Score 0
Code Size 481 Byte
Status WA
Exec Time 92 ms
Memory 14332 KB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 0 / 500
Status
AC × 3
AC × 9
WA × 7
Set Name Test Cases
Sample 00_example_01.txt, 00_example_02.txt, 00_example_03.txt
All 00_example_01.txt, 00_example_02.txt, 00_example_03.txt, 01.txt, 02.txt, 03.txt, 04.txt, 05.txt, 06.txt, 07.txt, 08.txt, 09.txt, 10.txt, 11.txt, 12.txt, 13.txt
Case Name Status Exec Time Memory
00_example_01.txt AC 7 ms 1788 KB
00_example_02.txt AC 7 ms 1788 KB
00_example_03.txt AC 7 ms 1788 KB
01.txt WA 63 ms 10236 KB
02.txt AC 42 ms 7420 KB
03.txt AC 10 ms 1916 KB
04.txt AC 7 ms 1788 KB
05.txt WA 86 ms 13052 KB
06.txt AC 70 ms 13052 KB
07.txt WA 19 ms 3580 KB
08.txt AC 19 ms 3708 KB
09.txt AC 11 ms 2172 KB
10.txt WA 21 ms 4220 KB
11.txt WA 75 ms 14332 KB
12.txt WA 75 ms 14332 KB
13.txt WA 92 ms 14332 KB