結果

問題 No.2209 Flip and Reverse
ユーザー daiotadaiota
提出日時 2023-02-10 23:09:52
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 727 bytes
コンパイル時間 1,450 ms
コンパイル使用メモリ 164,988 KB
実行使用メモリ 5,652 KB
最終ジャッジ日時 2023-09-22 00:15:04
合計ジャッジ時間 3,598 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 AC 2 ms
4,376 KB
testcase_04 AC 2 ms
4,380 KB
testcase_05 WA -
testcase_06 AC 2 ms
4,376 KB
testcase_07 WA -
testcase_08 AC 7 ms
5,560 KB
testcase_09 AC 1 ms
4,376 KB
testcase_10 WA -
testcase_11 AC 2 ms
4,380 KB
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 AC 12 ms
5,384 KB
testcase_19 AC 13 ms
5,380 KB
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 AC 12 ms
5,384 KB
testcase_24 AC 11 ms
5,432 KB
testcase_25 WA -
testcase_26 AC 11 ms
5,456 KB
testcase_27 AC 11 ms
5,452 KB
testcase_28 WA -
testcase_29 WA -
testcase_30 AC 7 ms
5,392 KB
testcase_31 WA -
testcase_32 AC 7 ms
5,384 KB
testcase_33 AC 7 ms
5,392 KB
権限があれば一括ダウンロードができます

ソースコード

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