結果
問題 |
No.2209 Flip and Reverse
|
ユーザー |
|
提出日時 | 2023-02-10 21:54:51 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 960 bytes |
コンパイル時間 | 1,997 ms |
コンパイル使用メモリ | 194,508 KB |
最終ジャッジ日時 | 2025-02-10 12:39:41 |
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 17 WA * 13 |
ソースコード
#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; } if(T != T_rev){ if(cnt % 2 == 1) ++cnt; if(revcnt % 2 == 0) ++revcnt; } cout << min(cnt, revcnt) << "\n"; }