結果

問題 No.2209 Flip and Reverse
ユーザー boatmusclesboatmuscles
提出日時 2023-02-10 21:32:02
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 17 ms / 2,000 ms
コード長 1,567 bytes
コンパイル時間 1,970 ms
コンパイル使用メモリ 150,844 KB
実行使用メモリ 5,596 KB
最終ジャッジ日時 2023-09-21 22:35:34
合計ジャッジ時間 3,988 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 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 2 ms
4,380 KB
testcase_05 AC 1 ms
4,376 KB
testcase_06 AC 2 ms
4,380 KB
testcase_07 AC 1 ms
4,380 KB
testcase_08 AC 8 ms
5,368 KB
testcase_09 AC 1 ms
4,376 KB
testcase_10 AC 2 ms
4,376 KB
testcase_11 AC 2 ms
4,376 KB
testcase_12 AC 2 ms
4,376 KB
testcase_13 AC 1 ms
4,380 KB
testcase_14 AC 17 ms
5,344 KB
testcase_15 AC 17 ms
5,408 KB
testcase_16 AC 17 ms
5,356 KB
testcase_17 AC 17 ms
5,436 KB
testcase_18 AC 17 ms
5,372 KB
testcase_19 AC 16 ms
5,368 KB
testcase_20 AC 17 ms
5,400 KB
testcase_21 AC 17 ms
5,372 KB
testcase_22 AC 17 ms
5,372 KB
testcase_23 AC 16 ms
5,424 KB
testcase_24 AC 15 ms
5,340 KB
testcase_25 AC 15 ms
5,596 KB
testcase_26 AC 15 ms
5,344 KB
testcase_27 AC 15 ms
5,412 KB
testcase_28 AC 9 ms
5,396 KB
testcase_29 AC 9 ms
5,388 KB
testcase_30 AC 8 ms
5,404 KB
testcase_31 AC 9 ms
5,368 KB
testcase_32 AC 9 ms
5,412 KB
testcase_33 AC 8 ms
5,404 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<cstdio>
#include<cassert>
#include<vector>
#include<iostream>
#include<string>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<functional>
#include<utility>
#include<cstring>
#include<numeric>
#include<algorithm>
#include<atcoder/math>
#include<atcoder/modint>
#include<ext/pb_ds/assoc_container.hpp>
//#include<ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
using namespace atcoder;
using ll = long long;
using ull = unsigned long long;
using Mint = modint998244353;
using mint = modint;
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define rrep(i, n) for (int i = (int)(n)-1; i >= 0; --i)
#define rep2(i, a, b) for (int i = (int)a; i < (int)(b); ++i)
#define rrep2(i, a, b) for (int i = (int)(b)-1; i >= (int)(a); --i)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
constexpr int dx[] = {-1,0,1,0};
constexpr int dy[] = {0,-1,0,1};
constexpr int MAX_N = 100000;
//ダイクストラ法:makedijkstra
//エラトステネスの篩:makesieve
//テストケースが複数の場合:multest

int main(){
    cin.tie(nullptr);
    std::ios_base::sync_with_stdio(false);
    int N;
    string S, T;
    cin >> N >> S >> T;
    int ans = N, ans1 = 0, ans2 = 0;
    rep(i, N) if(S[i] != T[i]) ++ans1;
    if(!(ans1&1)) ans = ans1;
    reverse(S.begin(), S.end());
    rep(i, N) if(S[i] != T[i]) ++ans2;
    if(ans2&1) chmin(ans, ans2);
    cout << ans << '\n';
}
0