Submission #1527826


Source Code Expand

Copy
n=gets.to_i
s=[0,1].map{gets.chomp}
pre_pattern=:none
cnt=1
i=0
while i<n
  case pre_pattern
  when :none
    if s[0][i]==s[1][i]
      x=3
      pre_pattern=:tate
    else
      x=6
      pre_pattern=:yoko
      i+=1
    end
  when :tate
    if s[0][i]==s[1][i]
      x=2
      pre_pattern=:tate
    else
      x=2
      pre_pattern=:yoko
      i+=1
    end
  when :yoko
    if s[0][i]==s[1][i]
      x=1
      pre_pattern=:tate
    else
      x=3
      pre_pattern=:yoko
      i+=1
    end
  end
  cnt = cnt*x%1000000007
  i+=1
end

p cnt

Submission Info

Submission Time
Task D - Coloring Dominoes
User mayumini
Language Ruby (2.3.3)
Score 400
Code Size 579 Byte
Status
Exec Time 7 ms
Memory 1788 KB

Test Cases

Set Name Score / Max Score Test Cases
Sample 0 / 0 sample1.txt, sample2.txt, sample3.txt
All 400 / 400 sample1.txt, sample2.txt, sample3.txt, 1.txt, 10.txt, 11.txt, 12.txt, 13.txt, 14.txt, 15.txt, 16.txt, 17.txt, 18.txt, 19.txt, 2.txt, 20.txt, 21.txt, 22.txt, 3.txt, 4.txt, 5.txt, 6.txt, 7.txt, 8.txt, 9.txt, sample1.txt, sample2.txt, sample3.txt
Case Name Status Exec Time Memory
1.txt 7 ms 1788 KB
10.txt 7 ms 1788 KB
11.txt 7 ms 1788 KB
12.txt 7 ms 1788 KB
13.txt 7 ms 1788 KB
14.txt 7 ms 1788 KB
15.txt 7 ms 1788 KB
16.txt 7 ms 1788 KB
17.txt 7 ms 1788 KB
18.txt 7 ms 1788 KB
19.txt 7 ms 1788 KB
2.txt 7 ms 1788 KB
20.txt 7 ms 1788 KB
21.txt 7 ms 1788 KB
22.txt 7 ms 1788 KB
3.txt 7 ms 1788 KB
4.txt 7 ms 1788 KB
5.txt 7 ms 1788 KB
6.txt 7 ms 1788 KB
7.txt 7 ms 1788 KB
8.txt 7 ms 1788 KB
9.txt 7 ms 1788 KB
sample1.txt 7 ms 1788 KB
sample2.txt 7 ms 1788 KB
sample3.txt 7 ms 1788 KB