Submission #11818681


Source Code Expand

Copy
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
import numpy as np
from numba import njit

MOD = 10**9 + 7

N = int(readline())
S = np.array(list(read().rstrip()), np.int8)

R = np.sum(S == ord('R'))
B = np.sum(S == ord('B'))
G = np.sum(S == ord('G'))

@njit
def f(S):
    N = len(S)
    ret = 0
    for i in range(N):
        for j in range(i + 1, N):
            k = j + j - i
            if k >= N:
                break
            if S[i] != S[j] and S[i] != S[k] and S[j] != S[k]:
                ret += 1
    return ret

answer = R * B * G - f(S)
print(answer)

Submission Info

Submission Time
Task D - RGB Triplets
User maspy
Language Python (3.8.2)
Score 400
Code Size 665 Byte
Status
Exec Time 798 ms
Memory 109716 KB

Judge Result

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 798 ms 109028 KB
sample_02 592 ms 109132 KB
testcase_0 591 ms 109612 KB
testcase_1 590 ms 109268 KB
testcase_10 584 ms 109284 KB
testcase_11 586 ms 109224 KB
testcase_12 588 ms 109128 KB
testcase_13 594 ms 109004 KB
testcase_14 598 ms 109244 KB
testcase_15 612 ms 109112 KB
testcase_16 600 ms 109620 KB
testcase_17 613 ms 109448 KB
testcase_18 600 ms 108904 KB
testcase_2 582 ms 109692 KB
testcase_3 602 ms 109140 KB
testcase_4 599 ms 109244 KB
testcase_5 591 ms 109112 KB
testcase_6 594 ms 109624 KB
testcase_7 603 ms 108944 KB
testcase_8 594 ms 109160 KB
testcase_9 604 ms 109716 KB