結果

問題 No.2018 X-Y-X
ユーザー okkuukenkenokkuukenken
提出日時 2022-07-22 23:19:22
言語 C++23
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 842 bytes
コンパイル時間 1,285 ms
コンパイル使用メモリ 129,884 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-09-17 12:20:59
合計ジャッジ時間 2,824 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#define _USE_MATH_DEFINES
#include<iostream>
#include<vector>
#include<algorithm>
#include<cmath>
#include<string>
#include<iomanip>
#include<numeric>
#include<queue>
#include<deque>
#include<stack>
#include<set>
#include<map>
#include<random>
using namespace std;
typedef long long ll;
const int mod=998244353;
ll mypow(int x,ll n){
	if(n==0)
		return 1;
	if(n%2==1)
		return mypow(x,n-1)*x%mod;
	ll res=mypow(x,n/2);
	return res*res%mod;
}
ll inv(int x){
	return mypow(x,mod-2);
}
int main(){
	int n;
	string s,t;
	cin>>n>>s>>t;
	if(s[0]!=t[0]||s[n-1]!=t[n-1])
		cout<<-1<<endl,exit(0);
	int ans=0,tmp=0;
	for(int i=0;i<n;i++){
		if(s[i]!=t[i]){
			ans++;
			tmp++;
		}else if(tmp>0){
			int cnt=0;
			for(int j=i-tmp;j<i;j++)
				if(s[j-1]==s[j+1])
					cnt++;
			if(cnt!=1)
				cout<<-1<<endl,exit(0);
			tmp=0;
		}
	}
	cout<<ans<<endl;
}
0