Submission #65570108


Source Code Expand

#include <iostream>
#include <vector>
#include <string>

int main() {
  int N;
  std::cin >> N;

  std::vector<std::string> S(N), T(N);
  for (int i = 0; i < N; i++) std::cin >> S[i];
  for (int i = 0; i < N; i++) std::cin >> T[i];

  int ans = 1e9;
  for (int kaiten = 0; kaiten <= 3; kaiten++) {
    int cnt = 0;
    for (int i = 0; i < N; i++) {
      for (int j = 0; j < N; j++) {
        if (S[i][j] != T[i][j]) cnt++;
      }
    }
    ans = std::min(ans, cnt + kaiten);

    std::vector<std::string> Ss(N, std::string(N, 'a'));
    for (int i = 0; i < N; i++) {
      for (int j = 0; j < N; j++) {
        Ss[i][j] = S[N-1 - j][i];
      }
    }
    S = Ss;
  }

  std::cout << ans << '\n';

  return 0;
}

Submission Info

Submission Time
Task B - Grid Rotation
User juten10x
Language C++ 17 (gcc 12.2)
Score 250
Code Size 748 Byte
Status AC
Exec Time 2 ms
Memory 3712 KiB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 250 / 250
Status
AC × 2
AC × 21
Set Name Test Cases
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
Case Name Status Exec Time Memory
random_01.txt AC 1 ms 3488 KiB
random_02.txt AC 1 ms 3544 KiB
random_03.txt AC 1 ms 3496 KiB
random_04.txt AC 1 ms 3568 KiB
random_05.txt AC 1 ms 3404 KiB
random_06.txt AC 2 ms 3560 KiB
random_07.txt AC 1 ms 3672 KiB
random_08.txt AC 1 ms 3632 KiB
random_09.txt AC 1 ms 3444 KiB
random_10.txt AC 2 ms 3712 KiB
random_11.txt AC 1 ms 3592 KiB
random_12.txt AC 2 ms 3440 KiB
random_13.txt AC 1 ms 3520 KiB
random_14.txt AC 1 ms 3580 KiB
random_15.txt AC 1 ms 3528 KiB
random_16.txt AC 1 ms 3644 KiB
random_17.txt AC 1 ms 3536 KiB
random_18.txt AC 1 ms 3400 KiB
random_19.txt AC 1 ms 3444 KiB
sample_01.txt AC 1 ms 3544 KiB
sample_02.txt AC 1 ms 3444 KiB