Submission #11848164


Source Code Expand

Copy
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()

Submission Info

Submission Time
Task D - RGB Triplets
User charter
Language Python (3.8.2)
Score 400
Code Size 441 Byte
Status
Exec Time 878 ms
Memory 9464 KB

Test Cases

Set Name Score / Max Score Test Cases
All 400 / 400 sample_01, sample_02, testcase_0, testcase_1, testcase_10, testcase_11, testcase_12, testcase_13, testcase_14, testcase_15, testcase_16, testcase_17, testcase_18, testcase_2, testcase_3, testcase_4, testcase_5, testcase_6, testcase_7, testcase_8, testcase_9
Sample 0 / 0 sample_01, sample_02
Case Name Status Exec Time Memory
sample_01 19 ms 9172 KB
sample_02 18 ms 9460 KB
testcase_0 19 ms 9328 KB
testcase_1 21 ms 9332 KB
testcase_10 33 ms 9404 KB
testcase_11 19 ms 9284 KB
testcase_12 23 ms 9272 KB
testcase_13 58 ms 9404 KB
testcase_14 41 ms 9460 KB
testcase_15 614 ms 9180 KB
testcase_16 260 ms 9184 KB
testcase_17 878 ms 9344 KB
testcase_18 678 ms 9292 KB
testcase_2 22 ms 9332 KB
testcase_3 19 ms 9176 KB
testcase_4 18 ms 9280 KB
testcase_5 18 ms 9332 KB
testcase_6 18 ms 9332 KB
testcase_7 18 ms 9464 KB
testcase_8 19 ms 9160 KB
testcase_9 19 ms 9396 KB