提出 #65447073


ソースコード 拡げる

import sys

def check_str(t,u):
    if len(t) < len(u):
        return False
    for i,c in enumerate(u):
        if t[i] not in {'?', u[i]}:
            return False
    return True

def rotate(N, a:[[]]) -> [[]]:
    b = [[0]*N for i in range(N)]
    for i in range(N):
        for j in range(N):
            b[j][N-1-i] = a[i][j]
    return b

def calc_diffs(N:int, S:[[]], T:[[]]) -> int:
    diffs = 0
    for i in range(N):
        for j in range(N):
            if S[i][j] != T[i][j]:
                diffs += 1
    return diffs

def main():
    input = sys.stdin.readline
    N = int(input())
    S = []
    T = []
    for _ in range(N):
        S.append(list(input()[:-1]))
    for _ in range(N):
        T.append(list(input()[:-1]))

    min_d = calc_diffs(N, S, T)
    S = rotate(N, S)
    min_d = min(min_d, calc_diffs(N, S, T)+1)
    S = rotate(N, S)
    min_d = min(min_d, calc_diffs(N, S, T)+2)
    S = rotate(N, S)
    min_d = min(min_d, calc_diffs(N, S, T)+3)

    print(min_d)

main()

提出情報

提出日時
問題 B - Grid Rotation
ユーザ Wasaw
言語 Python (PyPy 3.10-v7.3.12)
得点 250
コード長 1049 Byte
結果 AC
実行時間 66 ms
メモリ 81884 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 58 ms 80892 KiB
random_02.txt AC 62 ms 80596 KiB
random_03.txt AC 59 ms 80916 KiB
random_04.txt AC 63 ms 81316 KiB
random_05.txt AC 60 ms 80644 KiB
random_06.txt AC 59 ms 80684 KiB
random_07.txt AC 62 ms 80924 KiB
random_08.txt AC 64 ms 81884 KiB
random_09.txt AC 65 ms 81536 KiB
random_10.txt AC 66 ms 81652 KiB
random_11.txt AC 65 ms 81720 KiB
random_12.txt AC 65 ms 81696 KiB
random_13.txt AC 62 ms 81416 KiB
random_14.txt AC 63 ms 81720 KiB
random_15.txt AC 63 ms 81436 KiB
random_16.txt AC 64 ms 81624 KiB
random_17.txt AC 55 ms 76692 KiB
random_18.txt AC 55 ms 76432 KiB
random_19.txt AC 55 ms 76356 KiB
sample_01.txt AC 55 ms 76516 KiB
sample_02.txt AC 55 ms 76344 KiB