結果

問題 No.2209 Flip and Reverse
ユーザー tktk_snsntktk_snsn
提出日時 2023-02-10 21:28:46
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 9 ms / 2,000 ms
コード長 2,501 bytes
コンパイル時間 918 ms
コンパイル使用メモリ 103,848 KB
実行使用メモリ 5,592 KB
最終ジャッジ日時 2023-09-21 22:32:11
合計ジャッジ時間 2,789 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 2 ms
4,376 KB
testcase_03 AC 2 ms
4,376 KB
testcase_04 AC 1 ms
4,376 KB
testcase_05 AC 1 ms
4,376 KB
testcase_06 AC 1 ms
4,380 KB
testcase_07 AC 2 ms
4,376 KB
testcase_08 AC 8 ms
5,448 KB
testcase_09 AC 2 ms
4,376 KB
testcase_10 AC 1 ms
4,376 KB
testcase_11 AC 1 ms
4,380 KB
testcase_12 AC 2 ms
4,376 KB
testcase_13 AC 2 ms
4,376 KB
testcase_14 AC 9 ms
5,392 KB
testcase_15 AC 8 ms
5,328 KB
testcase_16 AC 9 ms
5,420 KB
testcase_17 AC 8 ms
5,388 KB
testcase_18 AC 8 ms
5,388 KB
testcase_19 AC 8 ms
5,384 KB
testcase_20 AC 8 ms
5,344 KB
testcase_21 AC 8 ms
5,408 KB
testcase_22 AC 8 ms
5,444 KB
testcase_23 AC 9 ms
5,372 KB
testcase_24 AC 9 ms
5,340 KB
testcase_25 AC 9 ms
5,344 KB
testcase_26 AC 9 ms
5,348 KB
testcase_27 AC 9 ms
5,592 KB
testcase_28 AC 9 ms
5,348 KB
testcase_29 AC 9 ms
5,452 KB
testcase_30 AC 9 ms
5,324 KB
testcase_31 AC 9 ms
5,440 KB
testcase_32 AC 9 ms
5,380 KB
testcase_33 AC 8 ms
5,344 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <sstream>
#include <vector>
#include <map>
#include <algorithm>
#include <set>
#include <stack>
#include <queue>
#include <cmath>
#include <iomanip>
#include <numeric>
#include <string>
#include <bitset>
#include <assert.h>
#include <functional>
#include <random>

// #define _GLIBCXX_DEBUG
// #define _LIBCPP_DEBUG 0
#define _GLIBCXX_DEQUE_BUF_SIZE 64

#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define revrep(i, n) for(int i = (int)(n - 1); i >= 0; --i)
#define range(i, s, t) for (int i = (int)(s); i < (int)(t); ++i)
#define revrange(i, s, t) for(int i = (int)(t - 1); i >= (int)(s); --i)
#define srange(i, s, t, step) for(int i = (int)(s); i < (int)(t); i+=int(step))
#define popcnt(x) __builtin_popcountll(x)
#define hayai std::ios::sync_with_stdio(false);std::cin.tie(nullptr)
#define SORT(x) sort(x.begin(), x.end())
#define ERASE(x) x.erase(unique(x.begin(), x.end()), x.end())

using namespace std;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<long long, long long>;
template<class T> inline bool chmax(T& a, T b){ if (a < b){ a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b){ if (a > b){ a = b; return true; } return false; }
inline bool inside(int x, int y, int h, int w) { return (x >= 0 && x < h && y >= 0 && y < w); }
constexpr pair<int, int> dydx4[] = { {0, 1}, {-1, 0}, {0, -1}, {1, 0}, };   //RULD
constexpr pair<int, int> dydx8[] = { {0, 1},{-1, 1},{-1, 0},{-1, -1},{0, -1},{1, -1},{1, 0},{1, 1}, };

namespace tktk {

void inline print() { cout << '\n'; }

template<class Head, class... Tail>
void print(Head&& head, Tail&&... tail) {
    cout << head;
    if(sizeof...(tail) != 0) cout << " ";
    print(forward<Tail>(tail)...);
}

template<class T> 
void print(vector<T> &vec) {
    for(auto &a: vec) {
        cout << a;
        if(&a != &vec.back()) cout << " ";
    }
    cout << endl;
}

template<class T>
void print(vector<vector<T>> &mat) {
    for(auto &vec: mat) {
        print(vec);
    }
}

}   //tktk


void solve() {
    int n;
    cin >> n;
    string s, t;
    cin >> s >> t;

    int ans = 100 * n;

    int cnt = 0;
    rep(i, n) cnt += s[i] != t[i];
    if(cnt % 2 == 0) {
        chmin(ans, cnt);
    }

    cnt = 0;
    reverse(s.begin(), s.end());
    rep(i, n) cnt += s[i] != t[i];
    if(cnt % 2 == 1) {
        chmin(ans, cnt);
    }
    cout << ans << endl;
}

int main() {
    hayai;
    // int t;
    // cin >> t;
    // rep(i, t) solve();
    solve();
}
0