結果

問題 No.2209 Flip and Reverse
ユーザー srjywrdnprkt
提出日時 2023-02-11 02:36:48
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 49 ms / 2,000 ms
コード長 613 bytes
コンパイル時間 996 ms
コンパイル使用メモリ 104,328 KB
最終ジャッジ日時 2025-02-10 14:00:35
ジャッジサーバーID
(参考情報)
judge1 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 30
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <vector>
#include <cmath>
#include <map>
#include <set>
#include <iomanip>
#include <queue>
#include <algorithm>
#include <numeric>
#include <deque>
#include <complex>
#include <cassert>

using namespace std;

int main(){

    int N, ans=1e9, cnt;
    string S, T;
    cin >> N >> S >> T;
    cnt = 0;
    for (int i=0; i<N; i++) if (S[i] != T[i]) cnt++;
    if (cnt % 2 == 0) ans = min(ans, cnt);

    reverse(S.begin(), S.end());
    cnt = 0;
    for (int i=0; i<N; i++) if (S[i] != T[i]) cnt++;
    if (cnt % 2 == 1) ans = min(ans, cnt);

    cout << ans << endl;

    return 0;
}
0