Submission #70909668
Source Code Expand
from collections import Counter
s = list(input())
c = Counter(s)
target = set(s)
ans = 10 ** 10
for tar in target:
t = s[:]
cnt = 0
while len(set(t)) != 1:
cnt += 1
new_t = []
for i in range(1, len(t)):
if t[i - 1] == tar or t[i] == tar:
new_t.append(tar)
else:
new_t.append(t[i])
t = new_t
ans = min(ans, cnt)
print(ans)
Submission Info
| Submission Time | |
|---|---|
| Task | A - Shrinking |
| User | shunta |
| Language | Python (PyPy 3.10-v7.3.12) |
| Score | 300 |
| Code Size | 449 Byte |
| Status | AC |
| Exec Time | 81 ms |
| Memory | 83132 KiB |
Judge Result
| Set Name | Sample | All | ||||
|---|---|---|---|---|---|---|
| Score / Max Score | 0 / 0 | 300 / 300 | ||||
| Status |
|
|
| Set Name | Test Cases |
|---|---|
| Sample | 0_00.txt, 0_01.txt, 0_02.txt, 0_03.txt |
| All | 0_00.txt, 0_01.txt, 0_02.txt, 0_03.txt, 1_00.txt, 1_01.txt, 1_02.txt, 1_03.txt, 1_04.txt, 1_05.txt, 1_06.txt, 1_07.txt, 1_08.txt, 1_09.txt |
| Case Name | Status | Exec Time | Memory |
|---|---|---|---|
| 0_00.txt | AC | 69 ms | 76740 KiB |
| 0_01.txt | AC | 69 ms | 76796 KiB |
| 0_02.txt | AC | 69 ms | 76520 KiB |
| 0_03.txt | AC | 77 ms | 81340 KiB |
| 1_00.txt | AC | 71 ms | 76832 KiB |
| 1_01.txt | AC | 75 ms | 81200 KiB |
| 1_02.txt | AC | 69 ms | 76784 KiB |
| 1_03.txt | AC | 71 ms | 81040 KiB |
| 1_04.txt | AC | 72 ms | 81376 KiB |
| 1_05.txt | AC | 73 ms | 80992 KiB |
| 1_06.txt | AC | 76 ms | 81972 KiB |
| 1_07.txt | AC | 78 ms | 81676 KiB |
| 1_08.txt | AC | 79 ms | 81676 KiB |
| 1_09.txt | AC | 81 ms | 83132 KiB |