結果

問題 No.2209 Flip and Reverse
ユーザー CoCo_Japan_panCoCo_Japan_pan
提出日時 2023-02-10 22:09:44
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 21 ms / 2,000 ms
コード長 953 bytes
コンパイル時間 2,185 ms
コンパイル使用メモリ 199,020 KB
実行使用メモリ 7,328 KB
最終ジャッジ日時 2023-09-21 23:25:41
合計ジャッジ時間 4,422 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 2 ms
4,376 KB
testcase_03 AC 2 ms
4,380 KB
testcase_04 AC 2 ms
4,380 KB
testcase_05 AC 1 ms
4,380 KB
testcase_06 AC 1 ms
4,380 KB
testcase_07 AC 2 ms
4,380 KB
testcase_08 AC 10 ms
7,176 KB
testcase_09 AC 1 ms
4,376 KB
testcase_10 AC 1 ms
4,380 KB
testcase_11 AC 1 ms
4,376 KB
testcase_12 AC 1 ms
4,380 KB
testcase_13 AC 2 ms
4,380 KB
testcase_14 AC 21 ms
7,168 KB
testcase_15 AC 21 ms
7,188 KB
testcase_16 AC 20 ms
7,124 KB
testcase_17 AC 21 ms
7,152 KB
testcase_18 AC 20 ms
7,112 KB
testcase_19 AC 20 ms
7,160 KB
testcase_20 AC 20 ms
7,184 KB
testcase_21 AC 20 ms
7,112 KB
testcase_22 AC 21 ms
7,288 KB
testcase_23 AC 21 ms
7,140 KB
testcase_24 AC 17 ms
7,328 KB
testcase_25 AC 18 ms
7,112 KB
testcase_26 AC 18 ms
7,172 KB
testcase_27 AC 18 ms
7,144 KB
testcase_28 AC 11 ms
7,136 KB
testcase_29 AC 11 ms
7,112 KB
testcase_30 AC 11 ms
7,148 KB
testcase_31 AC 12 ms
7,136 KB
testcase_32 AC 10 ms
7,104 KB
testcase_33 AC 11 ms
7,188 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
using ll = long long;

#define overload3(_1, _2, _3, name, ...) name
#define rep1(n) for(ll _ = 0; _ < (n); ++_)
#define rep2(i, n) for(ll i = 0; i < (n); ++i)
#define rep3(i, a, b) for(ll i = (a); i < (b); ++i)
#define rep(...) overload3(__VA_ARGS__, rep3, rep2, rep1)(__VA_ARGS__)

#define all(x) (x).begin(), (x).end()
template <class T> using vec = vector<T>;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    int N;
    cin >> N;
    string S, T;
    cin >> S >> T;
    string S_rev = S, T_rev = T;
    reverse_copy(all(S), S_rev.begin());
    reverse_copy(all(T), T_rev.begin());
    // cout << S << "\n" << S_rev << "\n";
    int cnt = 0, revcnt = 0;
    rep(i, N){
        if(T[i] != S[i]) ++cnt;
        if(T[i] != S_rev[i]) ++revcnt;
    }
    int ans = min(cnt, revcnt);
    if(cnt % 2 == 1) ans = revcnt;
    if(revcnt % 2 == 0) ans = cnt;
    cout << ans << "\n";
} 
0