結果
| 問題 |
No.2209 Flip and Reverse
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2023-02-10 23:18:14 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 777 bytes |
| コンパイル時間 | 1,281 ms |
| コンパイル使用メモリ | 167,908 KB |
| 実行使用メモリ | 5,724 KB |
| 最終ジャッジ日時 | 2024-07-07 17:15:36 |
| 合計ジャッジ時間 | 3,162 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| 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]){
if(S[0]==S[N-1]) ans+=2;
else ans++;
}
}
cout << ans << endl;
return 0;
}