結果
| 問題 |
No.3110 Like CPCTF?
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2025-04-20 00:22:40 |
| 言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
| 結果 |
AC
|
| 実行時間 | 207 ms / 2,000 ms |
| コード長 | 825 bytes |
| コンパイル時間 | 371 ms |
| コンパイル使用メモリ | 12,288 KB |
| 実行使用メモリ | 10,240 KB |
| 最終ジャッジ日時 | 2025-04-20 00:22:45 |
| 合計ジャッジ時間 | 2,859 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 16 |
ソースコード
import itertools
def is_cpctf_like(s):
# Check length first (must be 5)
if len(s) != 5:
return False
# Check S1 == S3
if s[0] != s[2]:
return False
# Check uniqueness of other positions (1, 3, 4)
# Only s[0] and s[2] can be the same, rest must be unique
positions = [s[0], s[1], s[2], s[3], s[4]]
return len(positions) == len(set(positions)) + 1 # because s[0] == s[2]
def count_cpctf_like_subsequences(n, s):
count = 0
# Generate all index combinations of 5 characters (non-contiguous allowed)
for indices in itertools.combinations(range(n), 5):
sub = ''.join(s[i] for i in indices)
if is_cpctf_like(sub):
count += 1
return count
# Input
n = int(input())
s = input().strip()
# Output
print(count_cpctf_like_subsequences(n, s))