Skip to content

Instantly share code, notes, and snippets.

@whatalnk
Created April 18, 2019 11:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save whatalnk/f73d15e3adf6b1a65a5a13cbf42eb61c to your computer and use it in GitHub Desktop.
Save whatalnk/f73d15e3adf6b1a65a5a13cbf42eb61c to your computer and use it in GitHub Desktop.
AtCoder ABC 122 C - GeT AC
n, q = gets.chomp.split(" ").map(&:to_i)
s = gets.chomp
ss = Array.new(n-1, 0)
(n-1).times do |i|
if s[i..(i+1)] == "AC"
ss[i] = 1
end
end
sss = Array.new(n, 0)
(n - 1).times do |i|
sss[i+1] = sss[i] + ss[i]
end
q.times do
l, r = gets.chomp.split(" ").map(&:to_i)
puts sss[r-1] - sss[l-1]
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment