提出 #47727313


ソースコード 拡げる

#!/usr/bin/env python
# coding: utf-8
import sys
import itertools

def i_in(): return int(sys.stdin.readline().rstrip())
def li_in(): return list(map(int, sys.stdin.readline().rstrip().split()))
def s_in(): return sys.stdin.readline().rstrip()
def ls_in(): return list(sys.stdin.readline().rstrip().split())


def solve1():
    n = i_in()
    s = s_in()
    ss = set(s)

    ss_darr = [[0 for i in range(n)] for j in range(len(ss))]
    for ss_i, ss_v in enumerate(ss):
        for i in range(len(s)):
            if s[i] == ss_v:
                if i == 0:
                    ss_darr[ss_i][i] = 1
                else:
                    ss_darr[ss_i][i] = ss_darr[ss_i][i - 1] + 1
            else:
                ss_darr[ss_i][i] = 0
    print(sum(map(max, ss_darr)))
    # for i in range(len(ss)):
    #     subst_dic[ss[i]] = 1
    # for i in range(n - 1):
    #     for j in range(i + 1, n):
    #         q = s[i:j]
    #         if not q in ss:
    #             ss.add(q)
    #         if any(ss[i:j] in )
    


def main():
    solve1()


if __name__ == '__main__':
    main()

提出情報

提出日時
問題 C - Count xxx
ユーザ pogin503
言語 Python (CPython 3.11.4)
得点 300
コード長 1134 Byte
結果 AC
実行時間 422 ms
メモリ 55948 KiB

ジャッジ結果

セット名 Sample All
得点 / 配点 0 / 0 300 / 300
結果
AC × 3
AC × 20
セット名 テストケース
Sample 00_sample_00.txt, 00_sample_01.txt, 00_sample_02.txt
All 00_sample_00.txt, 00_sample_01.txt, 00_sample_02.txt, 01_random_00.txt, 01_random_01.txt, 01_random_02.txt, 01_random_03.txt, 01_random_04.txt, 01_random_05.txt, 01_random_06.txt, 01_random_07.txt, 01_random_08.txt, 01_random_09.txt, 01_random_10.txt, 01_random_11.txt, 01_random_12.txt, 01_random_13.txt, 02_handmade_00.txt, 02_handmade_01.txt, 02_handmade_02.txt
ケース名 結果 実行時間 メモリ
00_sample_00.txt AC 10 ms 8976 KiB
00_sample_01.txt AC 9 ms 8928 KiB
00_sample_02.txt AC 10 ms 8900 KiB
01_random_00.txt AC 17 ms 11320 KiB
01_random_01.txt AC 35 ms 16900 KiB
01_random_02.txt AC 346 ms 42116 KiB
01_random_03.txt AC 422 ms 49912 KiB
01_random_04.txt AC 13 ms 9612 KiB
01_random_05.txt AC 357 ms 43548 KiB
01_random_06.txt AC 108 ms 17968 KiB
01_random_07.txt AC 371 ms 45180 KiB
01_random_08.txt AC 335 ms 41816 KiB
01_random_09.txt AC 298 ms 37276 KiB
01_random_10.txt AC 127 ms 23492 KiB
01_random_11.txt AC 277 ms 41112 KiB
01_random_12.txt AC 211 ms 31620 KiB
01_random_13.txt AC 35 ms 17020 KiB
02_handmade_00.txt AC 35 ms 17048 KiB
02_handmade_01.txt AC 47 ms 12348 KiB
02_handmade_02.txt AC 413 ms 55948 KiB