結果
| 問題 |
No.3110 Like CPCTF?
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2025-04-19 18:27:30 |
| 言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
| 結果 |
AC
|
| 実行時間 | 96 ms / 2,000 ms |
| コード長 | 950 bytes |
| コンパイル時間 | 526 ms |
| コンパイル使用メモリ | 12,416 KB |
| 実行使用メモリ | 10,496 KB |
| 最終ジャッジ日時 | 2025-04-19 18:27:32 |
| 合計ジャッジ時間 | 1,997 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 16 |
ソースコード
def is_cpctf_like(s):
# Check if string is of length 5
if len(s) != 5:
return False
# Check if characters at positions 0 and 2 are the same
if s[0] != s[2]:
return False
# Check if all other characters are different from each other
chars = [s[0], s[1], s[3], s[4]]
return len(set(chars)) == 4
def count_cpctf_substrings(s):
n = len(s)
count = 0
# Generate all possible 5-character combinations (not necessarily consecutive)
for i in range(n):
for j in range(i+1, n):
for k in range(j+1, n):
for l in range(k+1, n):
for m in range(l+1, n):
substring = s[i] + s[j] + s[k] + s[l] + s[m]
if is_cpctf_like(substring):
count += 1
return count
# Read input
n = int(input())
s = input()
# Output the result
print(count_cpctf_substrings(s))