提出 #74341157
ソースコード 拡げる
def f(lista, listb, k):
f = False
if lista[k-1] == lista[k+1] and lista[k-1] != listb[k-1] and lista[k+1] != listb[k+1]:
f = True
return f
t=int(input())
for _ in range(t):
n=int(input())
a=input().strip()
b=input().strip()
a = list(a); b = list(b); count = 0
if a[0] != b[0] or a[n-1] != b[n-1]:
print(-1)
continue
for i in range(1,n-1):
if f(a,b,i):
count += 1
if a[i] == "0":
a[i] = "1"
else:
a[i] = "0"
# c = []
# for i in range(1,n-1):
# c.append(i)
c = [i for i in range(1, n-1) if a[i] != b[i]]
while c:
for i in c[:]:
# print(c)
if a[i] == b[i]:
c.remove(i)
# break
continue
if a[i-1] == a[i+1]:
# print(a[i-1],a[i+1],i)
a[i] = b[i]
count += 1
# print("*")
c.remove(i)
# break
continue
print(count)
# print(c)
提出情報
| 提出日時 | |
|---|---|
| 問題 | A - Reversi 3 |
| ユーザ | akhiko |
| 言語 | Python (CPython 3.13.7) |
| 得点 | 0 |
| コード長 | 959 Byte |
| 結果 | TLE |
| 実行時間 | > 2000 ms |
| メモリ | 67904 KiB |
ジャッジ結果
| セット名 | Sample | All | ||||||
|---|---|---|---|---|---|---|---|---|
| 得点 / 配点 | 0 / 0 | 0 / 700 | ||||||
| 結果 |
|
|
| セット名 | テストケース |
|---|---|
| Sample | 00_sample_00.txt |
| All | 00_sample_00.txt, 01_test_00.txt, 01_test_01.txt, 01_test_02.txt, 01_test_03.txt, 01_test_04.txt, 01_test_05.txt, 01_test_06.txt, 01_test_07.txt, 01_test_08.txt, 01_test_09.txt, 01_test_10.txt, 01_test_11.txt, 01_test_12.txt, 01_test_13.txt, 01_test_14.txt, 01_test_15.txt, 01_test_16.txt, 01_test_17.txt, 01_test_18.txt, 01_test_19.txt, 01_test_20.txt, 01_test_21.txt, 01_test_22.txt, 01_test_23.txt, 01_test_24.txt, 01_test_25.txt, 01_test_26.txt, 01_test_27.txt, 01_test_28.txt |
| ケース名 | 結果 | 実行時間 | メモリ |
|---|---|---|---|
| 00_sample_00.txt | AC | 10 ms | 9336 KiB |
| 01_test_00.txt | TLE | > 2000 ms | 9212 KiB |
| 01_test_01.txt | TLE | > 2000 ms | 9172 KiB |
| 01_test_02.txt | TLE | > 2000 ms | 9292 KiB |
| 01_test_03.txt | TLE | > 2000 ms | 9336 KiB |
| 01_test_04.txt | TLE | > 2000 ms | 9288 KiB |
| 01_test_05.txt | TLE | > 2000 ms | 9184 KiB |
| 01_test_06.txt | TLE | > 2000 ms | 9288 KiB |
| 01_test_07.txt | TLE | > 2000 ms | 9340 KiB |
| 01_test_08.txt | TLE | > 2000 ms | 9428 KiB |
| 01_test_09.txt | TLE | > 2000 ms | 12040 KiB |
| 01_test_10.txt | TLE | > 2000 ms | 15656 KiB |
| 01_test_11.txt | TLE | > 2000 ms | 49980 KiB |
| 01_test_12.txt | AC | 31 ms | 27724 KiB |
| 01_test_13.txt | TLE | > 2000 ms | 50068 KiB |
| 01_test_14.txt | AC | 30 ms | 27764 KiB |
| 01_test_15.txt | TLE | > 2000 ms | 50424 KiB |
| 01_test_16.txt | TLE | > 2000 ms | 50200 KiB |
| 01_test_17.txt | TLE | > 2000 ms | 50236 KiB |
| 01_test_18.txt | TLE | > 2000 ms | 50184 KiB |
| 01_test_19.txt | TLE | > 2000 ms | 50068 KiB |
| 01_test_20.txt | TLE | > 2000 ms | 50124 KiB |
| 01_test_21.txt | TLE | > 2000 ms | 50192 KiB |
| 01_test_22.txt | TLE | > 2000 ms | 50180 KiB |
| 01_test_23.txt | TLE | > 2000 ms | 50076 KiB |
| 01_test_24.txt | TLE | > 2000 ms | 50148 KiB |
| 01_test_25.txt | AC | 187 ms | 27812 KiB |
| 01_test_26.txt | TLE | > 2000 ms | 50208 KiB |
| 01_test_27.txt | TLE | > 2000 ms | 27928 KiB |
| 01_test_28.txt | TLE | > 2000 ms | 67904 KiB |