結果

問題 No.2209 Flip and Reverse
ユーザー 杨娵隅
提出日時 2023-02-10 21:37:07
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 745 bytes
コンパイル時間 2,232 ms
コンパイル使用メモリ 194,628 KB
最終ジャッジ日時 2025-02-10 12:21:13
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 13 WA * 17
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

#define int long long

constexpr int maxn = 1e6 + 10;
constexpr int mod = 998244353;
constexpr int inf = 1e9;

inline void chmax(int &a, int b){a = max(a, b);}
inline void chmin(int &a, int b){a = min(a, b);}
inline void chadd(int &a, int b){a = (a + b) % mod;}

inline void solve()
{
  int n;
  cin >> n;
  string s, t;
  cin >> s >> t;

  string ns;
  int x = '0' ^ '1';
  for (int i = 0; i < n; i ++)
  {
    ns += s[i] ^ x;
  }
  int ans = 0, cnt = 2;
  for (int i = 0; i < n; i ++)
  {
    ans += s[i] != t[i];
    cnt += ns[i] != t[i];
  }
  cout << min(ans, cnt) << '\n';
}

signed main()
{
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  cout.tie(nullptr);
  
  solve();

  return 0;
}
0