Last active
April 13, 2020 03:13
-
-
Save monhime/5b34b2be5c16b1efb9c6ac0b9f8e70c8 to your computer and use it in GitHub Desktop.
ABC162 D問題 解答
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import sys | |
from collections import Counter | |
def input(): return sys.stdin.readline().rstrip() | |
def main(): | |
n=int(input()) | |
s=input() | |
c_s=Counter(s) | |
sum_a=0 | |
for diff in range(1,(n-1)//2+1): | |
for i in range(n-2*diff): | |
if s[i]!=s[i+diff] and s[i+diff]!=s[i+2*diff] and s[i]!=s[i+2*diff]: | |
sum_a+=1 | |
print(c_s['R']*c_s['G']*c_s['B']-sum_a) | |
if __name__=='__main__': | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment