真就纯模拟啊
#include <bits/stdc++.h>
using namespace std;
const int N = 1e6 + 10;
int n;
char S[N], T[N];
bool turn(int i)
{
if (i == 1 || i == n) return false;
if (S[i - 1] != S[i] && S[i] != S[i + 1]) return true;
return false;
}
int main()
{
int times;
scanf("%d", ×);
while (times --)
{
scanf("%s%s", T + 1, S + 1);
n = strlen(S + 1);
int res = 0;
bool cross = true;
for (int i = 1; i <= n; ++ i)
if (S[i] != T[i])
{
if (turn(i)) S[i] = T[i], res ++;
else
{
cross = false;
break;
}
}
if (cross) cout << res << endl;
else puts("-1");
}
return 0;
}