Please sign in first.
Submission #47684326
Source Code Expand
#ABC329C
from collections import defaultdict as dd
#入力受取
N=int(input()); S=[ord(i)-ord('a') for i in input()]+[-1]
#ランレングス圧縮
C=[]; cnt=1
for i in range(N):
if S[i]==S[i+1]: cnt+=1
if S[i]!=S[i+1]: C.append((S[i],cnt)); cnt=1
#各成分ごとの最長を調べる
D=dd(int)
for e,c in C: D[e]=max(D[e],c)
#答えを出力
ans=0
for e in D: ans+=D[e]
print(ans)
Submission Info
| Submission Time | |
|---|---|
| Task | C - Count xxx |
| User | navel_tos |
| Language | Python (PyPy 3.10-v7.3.12) |
| Score | 300 |
| Code Size | 422 Byte |
| Status | AC |
| Exec Time | 84 ms |
| Memory | 98200 KiB |
Judge Result
| Set Name | Sample | All | ||||
|---|---|---|---|---|---|---|
| Score / Max Score | 0 / 0 | 300 / 300 | ||||
| Status |
|
|
| Set Name | Test Cases |
|---|---|
| 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 |
| Case Name | Status | Exec Time | Memory |
|---|---|---|---|
| 00_sample_00.txt | AC | 66 ms | 76584 KiB |
| 00_sample_01.txt | AC | 66 ms | 76876 KiB |
| 00_sample_02.txt | AC | 66 ms | 77064 KiB |
| 01_random_00.txt | AC | 71 ms | 82884 KiB |
| 01_random_01.txt | AC | 73 ms | 86672 KiB |
| 01_random_02.txt | AC | 84 ms | 96796 KiB |
| 01_random_03.txt | AC | 84 ms | 98200 KiB |
| 01_random_04.txt | AC | 68 ms | 81668 KiB |
| 01_random_05.txt | AC | 81 ms | 90812 KiB |
| 01_random_06.txt | AC | 79 ms | 89908 KiB |
| 01_random_07.txt | AC | 79 ms | 88592 KiB |
| 01_random_08.txt | AC | 76 ms | 87016 KiB |
| 01_random_09.txt | AC | 84 ms | 96612 KiB |
| 01_random_10.txt | AC | 71 ms | 84324 KiB |
| 01_random_11.txt | AC | 74 ms | 86384 KiB |
| 01_random_12.txt | AC | 74 ms | 86500 KiB |
| 01_random_13.txt | AC | 73 ms | 86700 KiB |
| 02_handmade_00.txt | AC | 73 ms | 86340 KiB |
| 02_handmade_01.txt | AC | 84 ms | 97980 KiB |
| 02_handmade_02.txt | AC | 73 ms | 86612 KiB |