結果
問題 |
No.2209 Flip and Reverse
|
ユーザー |
|
提出日時 | 2023-02-10 23:09:52 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 727 bytes |
コンパイル時間 | 1,351 ms |
コンパイル使用メモリ | 166,800 KB |
実行使用メモリ | 6,948 KB |
最終ジャッジ日時 | 2024-07-07 17:10:23 |
合計ジャッジ時間 | 3,050 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 14 WA * 16 |
ソースコード
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef pair<ll,ll> P; #define REP(i,n) for(ll i=0;i<ll(n);i++) int a[110]; int main(void){ cin.tie(nullptr); ios_base::sync_with_stdio(false); int i,j,k; int N; string S,T; cin >> N >> S >> T; if(N==1){ cout << 1 << endl; return 0; } int c=0,ans=0; for(i=1;i<=N-2;i++){ if(S[i]!=T[i]) c++; } if(c%2==0){ ans+=c; if((S[0]==T[0] && S[N-1]!=T[N-1]) || (S[0]!=T[0] && S[N-1]==T[N-1])) ans++; else if(S[0]!=T[0] && S[N-1]!=T[N-1]) ans+=2; }else{ ans+=c; if((S[0]==T[0] && S[N-1]!=T[N-1]) || (S[0]!=T[0] && S[N-1]==T[N-1])) ans++; else if(S[0]==T[0] && S[N-1]==T[N-1]) ans++; } cout << ans << endl; return 0; }