結果
| 問題 |
No.2209 Flip and Reverse
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2023-02-10 22:09:44 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 21 ms / 2,000 ms |
| コード長 | 953 bytes |
| コンパイル時間 | 2,126 ms |
| コンパイル使用メモリ | 194,064 KB |
| 最終ジャッジ日時 | 2025-02-10 12:51:07 |
|
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 30 |
ソースコード
#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";
}