結果
| 問題 |
No.2209 Flip and Reverse
|
| コンテスト | |
| ユーザー |
AngrySadEight
|
| 提出日時 | 2022-12-27 15:12:59 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 60 ms / 2,000 ms |
| コード長 | 897 bytes |
| コンパイル時間 | 505 ms |
| コンパイル使用メモリ | 71,632 KB |
| 最終ジャッジ日時 | 2025-02-09 21:06:17 |
|
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| 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;
}
}
AngrySadEight