提出 #65443861


ソースコード 拡げる

n = int(input())
s = [list(input()) for _ in range(n)]
t = [list(input()) for _ in range(n)]


def rotate(s):
    sr = []
    for i in range(n):
        tmp = []
        for j in range(n):
            tmp.append(s[n - j - 1][i])
        sr.append(tmp)
    return sr


def calc(s, t):
    cost = 0
    for i in range(n):
        for j in range(n):
            if s[i][j] != t[i][j]:
                cost += 1
    return cost


s1 = rotate(s)
s2 = rotate(s1)
s3 = rotate(s2)

ans = min([calc(s, t), 1 + calc(s1, t), 2 + calc(s2, t), 3 + calc(s3, t)])
print(ans)

提出情報

提出日時
問題 B - Grid Rotation
ユーザ rainline
言語 Python (CPython 3.11.4)
得点 250
コード長 590 Byte
結果 AC
実行時間 14 ms
メモリ 9300 KiB

ジャッジ結果

セット名 Sample All
得点 / 配点 0 / 0 250 / 250
結果
AC × 2
AC × 21
セット名 テストケース
Sample sample_01.txt, sample_02.txt
All random_01.txt, random_02.txt, random_03.txt, random_04.txt, random_05.txt, random_06.txt, random_07.txt, random_08.txt, random_09.txt, random_10.txt, random_11.txt, random_12.txt, random_13.txt, random_14.txt, random_15.txt, random_16.txt, random_17.txt, random_18.txt, random_19.txt, sample_01.txt, sample_02.txt
ケース名 結果 実行時間 メモリ
random_01.txt AC 10 ms 8516 KiB
random_02.txt AC 10 ms 8812 KiB
random_03.txt AC 10 ms 8472 KiB
random_04.txt AC 11 ms 9072 KiB
random_05.txt AC 10 ms 8444 KiB
random_06.txt AC 11 ms 8376 KiB
random_07.txt AC 11 ms 8876 KiB
random_08.txt AC 12 ms 9068 KiB
random_09.txt AC 14 ms 9184 KiB
random_10.txt AC 13 ms 9192 KiB
random_11.txt AC 14 ms 9216 KiB
random_12.txt AC 13 ms 9200 KiB
random_13.txt AC 13 ms 9212 KiB
random_14.txt AC 14 ms 9300 KiB
random_15.txt AC 14 ms 9244 KiB
random_16.txt AC 12 ms 9144 KiB
random_17.txt AC 10 ms 8444 KiB
random_18.txt AC 9 ms 8424 KiB
random_19.txt AC 9 ms 8476 KiB
sample_01.txt AC 10 ms 8420 KiB
sample_02.txt AC 10 ms 8436 KiB