結果
| 問題 |
No.2018 X-Y-X
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2022-07-22 23:19:22 |
| 言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 842 bytes |
| コンパイル時間 | 1,465 ms |
| コンパイル使用メモリ | 131,708 KB |
| 実行使用メモリ | 6,948 KB |
| 最終ジャッジ日時 | 2024-07-04 08:07:55 |
| 合計ジャッジ時間 | 2,747 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 8 WA * 23 |
ソースコード
#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;
}