結果
問題 | No.2209 Flip and Reverse |
ユーザー |
|
提出日時 | 2023-02-22 01:51:41 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 97 ms / 2,000 ms |
コード長 | 914 bytes |
コンパイル時間 | 1,846 ms |
コンパイル使用メモリ | 194,392 KB |
最終ジャッジ日時 | 2025-02-10 19:52:24 |
ジャッジサーバーID (参考情報) |
judge4 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 30 |
ソースコード
#include <bits/stdc++.h> using namespace std; using ll = long long; using ld = long double; using vll = vector<long long>; using vvll = vector<vector<long long>>; using vs = vector<string>; #define lln \ ll n; \ cin >> n; #define REP(i, n) for (long long i = 0; i < n; i++) #define REP2(i, s, e) for (long long i = s; i < e; i++) #define UNIQUE_VECTOR(v) v.erase(unique(v.begin(), v.end())) ll gcd(ll x, ll y) { return (x % y) ? gcd(y, x % y) : y; } ll lcm(ll x, ll y) { return x / gcd(x, y) * y; } int main() { lln; string s, t; cin >> s >> t; ll cnt = 0; REP(i, n) { if (s[i] == '1') { cnt++; } if (t[i] == '1') { cnt--; } } if (cnt % 2) { reverse(t.begin(), t.end()); } else { } ll ans = 0; REP(i, n) { if (s[i] != t[i]) { ans++; } } cout << ans << endl; } /* 0110111010 1001010011 @@@@@.@..@ 0110111010 1100101001 @.@..@..@@ */