Submission
Status:
[PPPPPPPPPP]
Score: 100
User: Dormon
Problemset: 04.Corretc the wodr
Language: cpp
Time: 0.008 second
Submitted On: 2025-03-31 10:21:34
#include <iostream>
#include <cstring>
using namespace std;
void no(string a){
cout << "Cannot transform to " << a << '\n';
}
void solve(){
string a, b;
cin >> a >> b;
int n = a.size(), m = b.size();
if (n != m){
no(a);
return ;
}
int hash[256] = {0};
for (int i = 0;i < n;i++){
hash[a[i]]++;
hash[b[i]]--;
}
for (int i = 1;i < 256;i++)
if (hash[i]){
no(a);
return ;
}
int ans = 0;
for (int i = 0;i < n;i++){
if (a[i] == b[i]) continue;
for (int j = i + 1;j < n;j++){
if (a[i] == b[j]){
swap(b[i], b[j]);
ans++;
break;
}
}
}
cout << ans << '\n';
}
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(0);
int q;
cin >> q;
while (q--){
solve();
}
}