結果
| 問題 |
No.3061 Cut and Maximums
|
| コンテスト | |
| ユーザー |
qwewe
|
| 提出日時 | 2025-04-24 12:26:28 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 2,421 bytes |
| コンパイル時間 | 151 ms |
| コンパイル使用メモリ | 82,584 KB |
| 実行使用メモリ | 54,308 KB |
| 最終ジャッジ日時 | 2025-04-24 12:27:38 |
| 合計ジャッジ時間 | 4,639 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | WA * 3 |
| other | WA * 33 |
ソースコード
S = input().strip()
n = len(S)
found = False
for start in range(n):
for end in range(start + 1, n):
# Check if start and end are lowercase letters
if not S[start].islower() or not S[end].islower():
continue
K = set() # Characters to keep (odd positions in the substring)
R = set() # Characters to replace (even positions in substring and outside)
valid_sub = True
# Process the substring from start to end (inclusive)
for i in range(start, end + 1):
pos_in_sub = (i - start) + 1 # 1-based position in the substring
if pos_in_sub % 2 == 1: # Odd position in the substring
if S[i] == ' ':
valid_sub = False
break
c = S[i]
if c in R:
valid_sub = False
break
K.add(c)
else: # Even position in the substring
if S[i] != ' ':
R.add(S[i])
if not valid_sub:
continue
# Add characters outside the substring to R if they are letters
for i in range(n):
if i < start or i > end:
if S[i] != ' ':
R.add(S[i])
# Check if K and R are disjoint
if K & R:
continue
# Check all occurrences of K are within the substring's odd positions
valid_k = True
for c in K:
for i in range(n):
if (i < start or i > end) and S[i] == c:
valid_k = False
break
if start <= i <= end:
pos_in_sub = (i - start) + 1
if pos_in_sub % 2 == 0 and S[i] == c:
valid_k = False
break
if not valid_k:
break
if not valid_k:
continue
# Check all letters outside the substring are in R
valid_outside = True
for i in range(n):
if i < start or i > end:
if S[i] != ' ' and S[i] not in R:
valid_outside = False
break
if not valid_outside:
continue
found = True
break
if found:
break
print("Yes" if found else "NO")
qwewe