結果
| 問題 |
No.3061 Cut and Maximums
|
| コンテスト | |
| ユーザー |
lam6er
|
| 提出日時 | 2025-04-09 21:02:53 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,127 bytes |
| コンパイル時間 | 486 ms |
| コンパイル使用メモリ | 82,732 KB |
| 実行使用メモリ | 54,276 KB |
| 最終ジャッジ日時 | 2025-04-09 21:04:18 |
| 合計ジャッジ時間 | 3,197 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | WA * 3 |
| other | WA * 33 |
ソースコード
S = input().strip()
unique_letters = set(c for c in S if c != ' ')
found = False
# Precompute all possible subsets of unique letters using bitmask
from itertools import chain, combinations
def all_subsets(s):
return chain.from_iterable(combinations(s, r) for r in range(len(s)+1))
for subset in all_subsets(unique_letters):
R = set(subset)
transformed = []
for c in S:
if c == ' ':
transformed.append(' ')
elif c in R:
transformed.append(c)
else:
transformed.append(' ')
# Trim leading and trailing spaces
s = ''.join(transformed).strip()
if len(s) < 2:
continue
# Check all even positions (1-based) are spaces and odd are letters
valid = True
for i in range(len(s)):
if (i+1) % 2 == 1: # odd positions must be letters
if s[i] == ' ':
valid = False
break
else: # even positions must be spaces
if s[i] != ' ':
valid = False
break
if valid:
found = True
break
print("Yes" if found else "NO")
lam6er