結果

問題 No.2209 Flip and Reverse
ユーザー ninja-kidninja-kid
提出日時 2023-02-11 14:30:18
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 46 ms / 2,000 ms
コード長 1,131 bytes
コンパイル時間 4,297 ms
コンパイル使用メモリ 261,864 KB
実行使用メモリ 7,224 KB
最終ジャッジ日時 2023-09-22 11:43:51
合計ジャッジ時間 7,468 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 AC 1 ms
4,380 KB
testcase_04 AC 1 ms
4,376 KB
testcase_05 AC 1 ms
4,380 KB
testcase_06 AC 2 ms
4,376 KB
testcase_07 AC 2 ms
4,376 KB
testcase_08 AC 40 ms
7,224 KB
testcase_09 AC 2 ms
4,376 KB
testcase_10 AC 1 ms
4,380 KB
testcase_11 AC 1 ms
4,380 KB
testcase_12 AC 1 ms
4,380 KB
testcase_13 AC 2 ms
4,376 KB
testcase_14 AC 46 ms
7,000 KB
testcase_15 AC 46 ms
6,964 KB
testcase_16 AC 46 ms
7,000 KB
testcase_17 AC 46 ms
6,944 KB
testcase_18 AC 46 ms
6,988 KB
testcase_19 AC 46 ms
6,936 KB
testcase_20 AC 46 ms
6,944 KB
testcase_21 AC 46 ms
6,988 KB
testcase_22 AC 46 ms
6,960 KB
testcase_23 AC 46 ms
7,064 KB
testcase_24 AC 44 ms
7,000 KB
testcase_25 AC 44 ms
6,956 KB
testcase_26 AC 44 ms
7,064 KB
testcase_27 AC 44 ms
7,032 KB
testcase_28 AC 41 ms
7,176 KB
testcase_29 AC 41 ms
6,992 KB
testcase_30 AC 41 ms
6,936 KB
testcase_31 AC 41 ms
6,992 KB
testcase_32 AC 41 ms
6,992 KB
testcase_33 AC 41 ms
6,956 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#include <atcoder/all>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rrep(i, n, m) for (int i = (int)(n); i > (int)(m); i--)
using namespace atcoder;
using ll = long long;
const ll MOD1 = 1000000007LL;
const ll MOD2 = 998244353LL;
using namespace std;
const vector<pair<int, int>> dpos4 = {{1, 0}, {0, 1}, {-1, 0}, {0, -1}};
// const vector<pair<int, int>> dpos8 = {{-1, -1}, {-1, 0}, {-1, 1}, {0, -1}, {0, 1}, {1, -1}, {1, 0}, {1, 1}};
template <typename T>
bool chmax(T &a, const T &b) {
    if (a < b) {
        a = b;  // aをbで更新
        return true;
    }
    return false;
}
template <typename T>
bool chmin(T &a, const T &b) {
    if (a > b) {
        a = b;  // aをbで更新
        return true;
    }
    return false;
}


int main() {
    int N;
    cin >> N;
    string S, T;
    cin >> S >> T;
    ll ans = 1e18;
    ll cnt = 0;
    rep(i, N){
        if(S[i] != T[i]) cnt++;
    }
    if(cnt % 2 == 0) chmin(ans, cnt);
    cnt = 0;
    rep(i, N){
        if(S[N - 1 - i] != T[i]) cnt++;
    }
    if(cnt % 2 == 1) chmin(ans, cnt);
    cout << ans << endl;
	return 0;
}
0