Submission #2786319


Source Code Expand

N = gets.to_i
@s = s = gets.chomp

c = [
  [true, true],
  [true, false],
  [false, true],
  [false, false],
]

def check_at(n, ans)
  case ans[n]
  when true
    (@s[n] == "o" && ans[n-1] == ans[n+1]) || (@s[n] == "x" && ans[n-1] != ans[n+1])
  when false
    (@s[n] == "o" && ans[n-1] != ans[n+1]) || (@s[n] == "x" && ans[n-1] == ans[n+1])
  end
end

c.each do |ans|
  (N-2).times do |i|
    case
    when ans[i+1] && s[i+1] == "o"
      ans << ans[i]
    when ans[i+1] && s[i+1] == "x"
      ans << !ans[i]
    when !ans[i+1] && s[i+1] == "o"
      ans << !ans[i]
    else
      ans << ans[i]
    end
  end

  if check_at(0, ans) && check_at(-1, ans)
    puts ans.map { |i| i ? "S" : "W" }.join
    exit
  end
end
p -1

Submission Info

Submission Time
Task D - Menagerie
User kumojima
Language Ruby (2.3.3)
Score 500
Code Size 761 Byte
Status AC
Exec Time 197 ms
Memory 10236 KB

Compile Error

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

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 500 / 500
Status
AC × 3
AC × 16
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 AC 104 ms 6780 KB
02.txt AC 37 ms 4472 KB
03.txt AC 12 ms 1916 KB
04.txt AC 7 ms 1788 KB
05.txt AC 142 ms 8828 KB
06.txt AC 68 ms 7292 KB
07.txt AC 31 ms 2812 KB
08.txt AC 26 ms 2812 KB
09.txt AC 10 ms 1916 KB
10.txt AC 39 ms 2552 KB
11.txt AC 197 ms 10236 KB
12.txt AC 197 ms 10236 KB
13.txt AC 156 ms 9468 KB