Skip to content

Instantly share code, notes, and snippets.

@whatalnk
Created October 23, 2017 09:15
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save whatalnk/dbf6a5af514d7840877690e928cdeb0f to your computer and use it in GitHub Desktop.
Code Festival 2017 予選 C
s = gets.chomp.split("")
s.each_cons(2) do |x, y|
if x == "A" && y == "C"
puts "Yes"
exit
end
end
puts "No"
n = gets.chomp.to_i
a = gets.chomp.split(" ").map(&:to_i)
odd = 1
a.each do |x|
if x.even?
odd *= 2
end
end
puts 3**n - odd
s = gets.chomp
n = s.length
l = 0
r = n - 1
ans = 0
while true
break if l >= r
if s[l] == "x" && s[r] == "x"
l += 1
r -= 1
elsif s[l] == "x" && s[r] != "x"
ans += 1
l += 1
elsif s[l] != "x" && s[r] == "x"
ans += 1
r -= 1
else
if s[l] == s[r]
l += 1
r -= 1
else
puts -1
exit
end
end
end
puts ans
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment