# http://yukicoder.me/problems/432 # No.197 手品 hats=Array.new(2) hats[0]=gets.chomp num=gets.to_i hats[1]=gets.chomp apos = Array.new(2).map{ Array.new } (0...hats.length).each{|i| cnt = 0 hats[i].each_char.with_index{|c,j| if(c=='o') apos[i][cnt] = j; cnt+=1 end } } if apos[0].length != apos[1].length puts "SUCCESS" exit end difftotal = 0 (0...apos[0].length).each{|i| diff = (apos[0][i] - apos[1][i]).abs difftotal += diff } if difftotal > num || (num-difftotal)%2==1 puts "SUCCESS" else puts "FAILURE" end