| Task: | Bittijono |
| Sender: | Username* |
| Submission time: | 2026-01-17 16:20:49 +0200 |
| Language: | Python3 (CPython3) |
| Status: | READY |
| Result: | 21 |
| group | verdict | score |
|---|---|---|
| #1 | ACCEPTED | 21 |
| #2 | RUNTIME ERROR | 0 |
| #3 | RUNTIME ERROR | 0 |
| test | verdict | time | group | |
|---|---|---|---|---|
| #1 | ACCEPTED | 0.15 s | 1, 3 | details |
| #2 | ACCEPTED | 0.69 s | 1, 2, 3 | details |
| #3 | ACCEPTED | 0.60 s | 1, 3 | details |
| #4 | ACCEPTED | 0.52 s | 1, 3 | details |
| #5 | ACCEPTED | 0.64 s | 1, 3 | details |
| #6 | RUNTIME ERROR | 0.69 s | 3 | details |
| #7 | RUNTIME ERROR | 0.69 s | 2, 3 | details |
| #8 | RUNTIME ERROR | 0.69 s | 3 | details |
| #9 | RUNTIME ERROR | 0.69 s | 2, 3 | details |
| #10 | RUNTIME ERROR | 0.69 s | 2, 3 | details |
| #11 | RUNTIME ERROR | 0.69 s | 3 | details |
| #12 | RUNTIME ERROR | 0.69 s | 2, 3 | details |
| #13 | RUNTIME ERROR | 0.69 s | 3 | details |
| #14 | RUNTIME ERROR | 0.69 s | 3 | details |
| #15 | RUNTIME ERROR | 0.69 s | 3 | details |
| #16 | ACCEPTED | 0.02 s | 1, 2, 3 | details |
| #17 | ACCEPTED | 0.89 s | 1, 3 | details |
| #18 | ACCEPTED | 0.91 s | 1, 3 | details |
| #19 | RUNTIME ERROR | 0.69 s | 3 | details |
| #20 | RUNTIME ERROR | 0.69 s | 3 | details |
Code
INF = 10**10
n, a, b = [int(x) for x in input().split()]
str1 = input()
str2 = input()
dp = {}
for x in range(2**n):
bstr = str(bin(x)).replace("0b","")
bstr = "0"*(n-len(bstr)) + bstr
dp[bstr] = INF
#print(bstr)
dp[str1] = 0
def op1(bstr, i):
res = bstr[:i] + ("0" if bstr[i] == "1" else "1") + bstr[i+1:]
return res
def op2(bstr, n, m):
res = bstr
for i in range(n,m+1):
res = op1(res,i)
return res
def step(bstr, depth, cost):
if(depth > 7):
return
for i in range(n):
test = op1(bstr,i)
if(cost+a < dp[test]):
dp[test]=cost+a
step(test,depth+1,cost+a)
for i in range(n):
for j in range(n-i):
test = op2(bstr, i, i+j)
if(cost+b < dp[test]):
dp[test]=cost+b
step(test,depth+1,cost+b)
step(str1, 0, 0)
#print(dp)
print(dp[str2])Test details
Test 1 (public)
Group: 1, 3
Verdict: ACCEPTED
| input |
|---|
| 8 3 5 10110001 01101000 |
| correct output |
|---|
| 11 |
| user output |
|---|
| 11 |
Test 2
Group: 1, 2, 3
Verdict: ACCEPTED
| input |
|---|
| 10 644 644 0111000100 0000010111 |
| correct output |
|---|
| 1932 |
| user output |
|---|
| 1932 |
Test 3
Group: 1, 3
Verdict: ACCEPTED
| input |
|---|
| 10 493 986 0001110000 0001100001 |
| correct output |
|---|
| 986 |
| user output |
|---|
| 986 |
Test 4
Group: 1, 3
Verdict: ACCEPTED
| input |
|---|
| 10 240 720 1011001110 1000000001 |
| correct output |
|---|
| 1200 |
| user output |
|---|
| 1200 |
Test 5
Group: 1, 3
Verdict: ACCEPTED
| input |
|---|
| 10 3 7 1110111111 0010010101 |
| correct output |
|---|
| 15 |
| user output |
|---|
| 15 |
Test 6
Group: 3
Verdict: RUNTIME ERROR
| input |
|---|
| 100000 1 1000000000 001100110010101001010111000110... |
| correct output |
|---|
| 50252 |
| user output |
|---|
| (empty) |
Test 7
Group: 2, 3
Verdict: RUNTIME ERROR
| input |
|---|
| 100000 1000000000 1 110010000110110100110110101011... |
| correct output |
|---|
| 25055 |
| user output |
|---|
| (empty) |
Test 8
Group: 3
Verdict: RUNTIME ERROR
| input |
|---|
| 100000 1000 1000000000 001001101010100000011110000101... |
| correct output |
|---|
| 50001000 |
| user output |
|---|
| (empty) |
Test 9
Group: 2, 3
Verdict: RUNTIME ERROR
| input |
|---|
| 100000 1000000000 1000 101010110001010011011011101110... |
| correct output |
|---|
| 24939000 |
| user output |
|---|
| (empty) |
Test 10
Group: 2, 3
Verdict: RUNTIME ERROR
| input |
|---|
| 100000 1000000000 1000000000 001000000001000000000010110111... |
| correct output |
|---|
| 25023000000000 |
| user output |
|---|
| (empty) |
Test 11
Group: 3
Verdict: RUNTIME ERROR
| input |
|---|
| 100000 123456789 987654321 100010110100011000001111001110... |
| correct output |
|---|
| 5475678967593 |
| user output |
|---|
| (empty) |
Test 12
Group: 2, 3
Verdict: RUNTIME ERROR
| input |
|---|
| 100000 987654321 123456789 000100110000010110111101111101... |
| correct output |
|---|
| 3071481453531 |
| user output |
|---|
| (empty) |
Test 13
Group: 3
Verdict: RUNTIME ERROR
| input |
|---|
| 100000 1000000 1000000000 001100110010100011000111101100... |
| correct output |
|---|
| 49916000000 |
| user output |
|---|
| (empty) |
Test 14
Group: 3
Verdict: RUNTIME ERROR
| input |
|---|
| 100000 10000000 1000000000 110111101101111110100101011000... |
| correct output |
|---|
| 494930000000 |
| user output |
|---|
| (empty) |
Test 15
Group: 3
Verdict: RUNTIME ERROR
| input |
|---|
| 100000 100000000 1000000000 111110000010100011011100110010... |
| correct output |
|---|
| 4547300000000 |
| user output |
|---|
| (empty) |
Test 16
Group: 1, 2, 3
Verdict: ACCEPTED
| input |
|---|
| 1 1 1 1 1 |
| correct output |
|---|
| 0 |
| user output |
|---|
| 0 |
Test 17
Group: 1, 3
Verdict: ACCEPTED
| input |
|---|
| 10 600 800 0000000000 1110111111 |
| correct output |
|---|
| 1400 |
| user output |
|---|
| 1400 |
Test 18
Group: 1, 3
Verdict: ACCEPTED
| input |
|---|
| 10 300 599 1101001010 0011010110 |
| correct output |
|---|
| 1198 |
| user output |
|---|
| 1198 |
Test 19
Group: 3
Verdict: RUNTIME ERROR
| input |
|---|
| 100000 300000000 500000000 010011101001001010010101101101... |
| correct output |
|---|
| 10000000000000 |
| user output |
|---|
| (empty) |
Test 20
Group: 3
Verdict: RUNTIME ERROR
| input |
|---|
| 100000 60000 1000000000 110110111011010100001000011011... |
| correct output |
|---|
| 3000000000 |
| user output |
|---|
| (empty) |
