結果

問題 No.2209 Flip and Reverse
ユーザー yansi819
提出日時 2024-04-11 09:08:01
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 55 ms / 2,000 ms
コード長 681 bytes
コンパイル時間 4,255 ms
コンパイル使用メモリ 251,092 KB
最終ジャッジ日時 2025-02-20 23:50:03
ジャッジサーバーID
(参考情報)
judge1 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 30
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#include <atcoder/all>
using namespace std;
using namespace atcoder;
using ll = long long;
using ld = long double;
using mint = modint998244353;

int main() {
  int n; cin >> n;
  string s, t; cin >> s >> t;
  int cnts = 0, cntt = 0;
  for (int i = 0; i < n; i++) {
    if (s[i] == '1') cnts++;
  }
  for (int i = 0; i < n; i++) {
    if (t[i] == '1') cntt++;
  }
  if (cnts % 2 == cntt % 2) {
    int cnt = 0;
    for (int i = 0; i < n; i++) {
      if (s[i] != t[i]) cnt++;
    }
    cout << cnt << endl;
  } else {
    int cnt = 0;
    for (int i = 0; i < n; i++) {
      if (s[n - 1 - i] != t[i]) cnt++;
    }
    cout << cnt << endl;
  }
  return 0;
}
0