結果

問題 No.2209 Flip and Reverse
コンテスト
ユーザー Mohamed Magdy
提出日時 2024-03-15 03:24:09
言語 C++14
(gcc 15.2.0 + boost 1.89.0)
コンパイル:
g++-15 -O2 -lm -std=c++14 -Wuninitialized -DONLINE_JUDGE -o a.out _filename_
実行:
./a.out
結果
AC  
実行時間 9 ms / 2,000 ms
コード長 571 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 1,177 ms
コンパイル使用メモリ 184,260 KB
実行使用メモリ 7,976 KB
最終ジャッジ日時 2026-04-16 06:06:37
合計ジャッジ時間 4,080 ms
ジャッジサーバーID
(参考情報)
judge3_1 / judge2_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 30
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

#include <bits/stdc++.h>

using namespace std;

using ll = long long;

#define sz(a) (int)(a.size())
#define debug(x) cout << "> " << (#x) << " = " << x << endl;
#define all(a) (a).begin(), (a).end()

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int n;
  cin >> n;
  string s, t;
  cin >> s >> t;
  int cnt1 = 0, cnt2 = 0;
  int bal = 0;
  for (int i = 0; i < n; i++) {
    if (s[i] != t[i]) {
      cnt1++;
      bal ^= 1;
    }
    if (s[i] != t[n - i - 1]) {
      cnt2++;
    }
  }
  if (!bal) cout << cnt1 << "\n";
  else cout << cnt2 << "\n";
}
0