結果
問題 | No.2209 Flip and Reverse |
ユーザー |
|
提出日時 | 2023-02-10 21:31:17 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 17 ms / 2,000 ms |
コード長 | 530 bytes |
コンパイル時間 | 3,563 ms |
コンパイル使用メモリ | 251,760 KB |
最終ジャッジ日時 | 2025-02-10 12:16:41 |
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 30 |
ソースコード
#include<bits/stdc++.h>using namespace std;#include<atcoder/all>using namespace atcoder;using ll = long long;int n;string s,t;void solve(){int ans = n;int cur = 0;for(int i = n-1;i>=0;i--){if(s[i]!=t[i]){cur++;}}if(cur%2==0){ans = cur;}reverse(s.begin(),s.end());cur = 0;for(int i = n-1;i>=0;i--){if(s[i]!=t[i]){cur++;}}if(cur%2==1){ans = min(ans,cur);}cout<<ans<<endl;}signed main(){cin.tie(nullptr);ios::sync_with_stdio(false);cin >> n >> s >> t;solve();}