結果
| 問題 | No.2209 Flip and Reverse |
| コンテスト | |
| ユーザー |
👑 |
| 提出日時 | 2022-12-27 15:12:59 |
| 言語 | C++17 (gcc 15.2.0 + boost 1.90.0) |
| 結果 |
AC
|
| 実行時間 | 36 ms / 2,000 ms |
| コード長 | 897 bytes |
| 記録 | |
| コンパイル時間 | 630 ms |
| コンパイル使用メモリ | 91,088 KB |
| 実行使用メモリ | 7,332 KB |
| 最終ジャッジ日時 | 2026-06-29 04:17:21 |
| 合計ジャッジ時間 | 2,580 ms |
|
ジャッジサーバーID (参考情報) |
judge2_1 / judge3_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 30 |
ソースコード
#include <iostream>
#include <string>
#include <cassert>
#include <algorithm>
using namespace std;
int main(){
int N;
string S;
string T;
cin >> N;
cin >> S;
cin >> T;
assert(1 <= N && N <= 1000000);
assert(S.size() == N);
assert(T.size() == N);
int parity_s = 0;
int parity_t = 0;
for (int i = 0; i < N; i++){
assert(S[i] == '0' || S[i] == '1');
assert(T[i] == '0' || T[i] == '1');
if (S[i] == '1') parity_s++;
if (T[i] == '1') parity_t++;
}
if (parity_s % 2 == parity_t % 2){
int ans = 0;
for (int i = 0; i < N; i++){
if (S[i] != T[i]) ans++;
}
cout << ans << endl;
}
else{
reverse(S.begin(), S.end());
int ans = 0;
for (int i = 0; i < N; i++){
if (S[i] != T[i]) ans++;
}
cout << ans << endl;
}
}