結果
| 問題 |
No.3110 Like CPCTF?
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2025-04-19 22:20:45 |
| 言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
| 結果 |
AC
|
| 実行時間 | 190 ms / 2,000 ms |
| コード長 | 623 bytes |
| コンパイル時間 | 271 ms |
| コンパイル使用メモリ | 12,032 KB |
| 実行使用メモリ | 10,240 KB |
| 最終ジャッジ日時 | 2025-04-19 22:20:48 |
| 合計ジャッジ時間 | 2,622 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 16 |
ソースコード
from itertools import combinations
from collections import Counter
def is_cpctf(s):
# s: 長さ5の文字列リスト ['A','B','A','C','D']
if s[0] != s[2]:
return False
counter = Counter(s)
return counter[s[0]] == 2 and all(count == 1 for ch, count in counter.items() if ch != s[0])
def count_cpctf_subsequences(N, S):
count = 0
indices = list(range(N))
for comb in combinations(indices, 5):
chars = [S[i] for i in comb]
if is_cpctf(chars):
count += 1
return count
# 入力例
N = int(input())
S = input().strip()
print(count_cpctf_subsequences(N, S))