結果

問題 No.2209 Flip and Reverse
ユーザー daiota
提出日時 2023-02-10 22:50:03
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 723 bytes
コンパイル時間 1,427 ms
コンパイル使用メモリ 167,324 KB
実行使用メモリ 5,848 KB
最終ジャッジ日時 2024-07-07 16:53:55
合計ジャッジ時間 2,961 ms
ジャッジサーバーID
(参考情報)
judge3 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 14 WA * 16
権限があれば一括ダウンロードができます

ソースコード

diff #

#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;
}
0