結果
問題 | No.2209 Flip and Reverse |
ユーザー |
|
提出日時 | 2023-02-11 14:30:18 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 46 ms / 2,000 ms |
コード長 | 1,131 bytes |
コンパイル時間 | 3,498 ms |
コンパイル使用メモリ | 250,792 KB |
最終ジャッジ日時 | 2025-02-10 14:22:55 |
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 30 |
ソースコード
#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;}