Submission #213513

#TimeUsernameProblemLanguageResultExecution timeMemory
213513tatyamMiners (IOI07_miners)Cpython 3
60 / 100
1600 ms4348 KiB
def kinds(a, b, c): if a > b: a, b = b, a if b > c: b, c = c, b if a > b: a, b = b, a ans = 3 if not a or a == b: ans -= 1 if not b or b == c: ans -= 1 return ans INF = 0x3fffffff input() s = [1 if i == 'B' else 2 if i == 'F' else 3 for i in input()] dp1 = [-INF] * 2 ** 8 dp1[0] = 0 for c in s: dp2 = [-INF] * 2 ** 8 for i in range(2 ** 8): a1 = i >> 6 & 3 a2 = i >> 4 & 3 b1 = i >> 2 & 3 b2 = i & 3 j = a2 << 6 | c << 4 | b1 << 2 | b2 dp2[j] = max(dp2[j], dp1[i] + kinds(a1, a2, c)) j = a1 << 6 | a2 << 4 | b2 << 2 | c dp2[j] = max(dp2[j], dp1[i] + kinds(b1, b2, c)) dp1 = dp2 print(max(dp1))
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...