Submission #2417242
Source Code Expand
def solve( s , c ): cnt = int(0) while 1 : if len(s) == 0 : return cnt f = True for i in range(len(s)): if s[i] != c: f = False break if f : return cnt s2 = "" for i in range(len(s)-1): if s[i] == c or s[i+1] == c: s2 += c else: s2 += s[i] s = s2 cnt += 1 return cnt; s = input() a = [0 for i in range(26)] for i in range(len(s)): a[ord(s[i])-ord('a')] += 1 ans = 0x7FFFFFFF for i in range(26): if(a[i] > 0 ): ans = min( ans , solve(s, chr( i + ord('a') ) ) ) print(ans)
Submission Info
Submission Time | |
---|---|
Task | A - Shrinking |
User | walk_to_work |
Language | Python (3.4.3) |
Score | 300 |
Code Size | 762 Byte |
Status | AC |
Exec Time | 34 ms |
Memory | 3064 KB |
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 | 17 ms | 3064 KB |
0_01.txt | AC | 17 ms | 3064 KB |
0_02.txt | AC | 17 ms | 3064 KB |
0_03.txt | AC | 18 ms | 3064 KB |
1_00.txt | AC | 17 ms | 3064 KB |
1_01.txt | AC | 19 ms | 3064 KB |
1_02.txt | AC | 17 ms | 3064 KB |
1_03.txt | AC | 17 ms | 3064 KB |
1_04.txt | AC | 18 ms | 3064 KB |
1_05.txt | AC | 18 ms | 3064 KB |
1_06.txt | AC | 20 ms | 3064 KB |
1_07.txt | AC | 21 ms | 3064 KB |
1_08.txt | AC | 29 ms | 3064 KB |
1_09.txt | AC | 34 ms | 3064 KB |