結果
| 問題 |
No.3061 Cut and Maximums
|
| コンテスト | |
| ユーザー |
gew1fw
|
| 提出日時 | 2025-06-12 14:14:47 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,348 bytes |
| コンパイル時間 | 169 ms |
| コンパイル使用メモリ | 82,788 KB |
| 実行使用メモリ | 54,424 KB |
| 最終ジャッジ日時 | 2025-06-12 14:14:54 |
| 合計ジャッジ時間 | 4,359 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| 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):
length = end - start + 1
valid = True
B = set() # Characters in odd positions (1-based) of the substring
C = set() # Characters in even positions (1-based) that need to be replaced with space
for i in range(length):
pos = start + i
char = S[pos]
if (i + 1) % 2 == 1: # Odd position (1-based)
if char == ' ':
valid = False
break
B.add(char)
else: # Even position (1-based)
if char != ' ':
C.add(char)
if not valid:
continue
# Collect characters in the surrounding areas (A)
A = set()
# Check before start
for i in range(start):
c = S[i]
if c != ' ':
A.add(c)
# Check after end
for i in range(end + 1, n):
c = S[i]
if c != ' ':
A.add(c)
# Check if B and (A ∪ C) are disjoint
if B.intersection(A) or B.intersection(C):
continue
found = True
break
if found:
break
print("Yes" if found else "NO")
gew1fw