Submission #65484195


Source Code Expand

// https://atcoder.jp/contests/abc404/tasks/abc404_b
// 2025年05月03日 21時01分56秒
#include <bits/stdc++.h>
// #include <atcoder/all>
// using namespace atcoder;
// using mint = modint998244353;
// using mint = modint1000000007;
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define rep(i, n) for (long long int i = 0; i < (n); ++i)
#define rep2(i, k, n) for (long long int i = (k); i < (n); ++i)
using namespace std;
using ll = long long;
using vint = vector<int>;
using vll = vector<ll>;
using vvint = vector<vector<int>>;
using vvll = vector<vector<ll>>;

const ll INF = (ll)2e18 + 9;
// const int INF = (int)2e9 + 7;

template <typename T>
void chmin(T& a, T b) {
    a = min(a, b);
}
template <typename T>
void chmax(T& a, T b) {
    a = max(a, b);
}

template <typename T>
void print(vector<T> v) {
    int n = v.size();
    rep(i, n) {
        if (i == 0)
            cout << v[i];
        else
            cout << ' ' << v[i];
    }
    cout << endl;
}

void yesno(bool x) {
    cout << (x ? "Yes" : "No") << '\n';
}

void solve();

int main() {
    solve();
    return 0;
}

template <typename T>
vector<vector<T>> rotr90(vector<vector<T>>& mat) {
    vector<vector<T>> newmat = mat;
    int N = mat.size();
    rep(i, N) {
        rep(j, N) {
            // newmat[j][N - 1 - i] = mat[i][j];
            newmat[i][j] = mat[N - j - 1][i];
        }
    }
    return newmat;
}

void solve() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);

    int N;
    cin >> N;
    vector S(N, vector<char>(N)), T(N, vector<char>(N));
    rep(i, N) rep(j, N) cin >> S[i][j];
    rep(i, N) rep(j, N) cin >> T[i][j];

    ll ans = INF;
    rep(k, 4) {
        if (k)
            S = rotr90(S);
        ll cnt = k;
        rep(i, N) rep(j, N) {
            if (S[i][j] != T[i][j])
                cnt++;
        }
        chmin(ans, cnt);
    }
    cout << ans << endl;
}

Submission Info

Submission Time
Task B - Grid Rotation
User goropikari
Language C++ 23 (gcc 12.2)
Score 250
Code Size 2007 Byte
Status AC
Exec Time 1 ms
Memory 3644 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 3460 KiB
random_02.txt AC 1 ms 3528 KiB
random_03.txt AC 1 ms 3528 KiB
random_04.txt AC 1 ms 3612 KiB
random_05.txt AC 1 ms 3400 KiB
random_06.txt AC 1 ms 3532 KiB
random_07.txt AC 1 ms 3612 KiB
random_08.txt AC 1 ms 3420 KiB
random_09.txt AC 1 ms 3544 KiB
random_10.txt AC 1 ms 3632 KiB
random_11.txt AC 1 ms 3556 KiB
random_12.txt AC 1 ms 3632 KiB
random_13.txt AC 1 ms 3632 KiB
random_14.txt AC 1 ms 3644 KiB
random_15.txt AC 1 ms 3544 KiB
random_16.txt AC 1 ms 3568 KiB
random_17.txt AC 1 ms 3448 KiB
random_18.txt AC 1 ms 3456 KiB
random_19.txt AC 1 ms 3608 KiB
sample_01.txt AC 1 ms 3524 KiB
sample_02.txt AC 1 ms 3532 KiB