Submission
Status:
[PPPPPPPPPP]
Score: 100
User: FotoFatTurtle
Problemset: 04.Corretc the wodr
Language: cpp
Time: 0.005 second
Submitted On: 2025-04-02 14:43:36
#include <bits/stdc++.h>
using namespace std;
#define f first
#define s second
int main(void)
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
int time;
cin>>time;
for(int ti=0;ti<time;ti++)
{
string want,s;
cin>>want>>s;
if(want.length()!=s.length())
{
cout<<"Cannot transform to "<<want<<"\n";
}
int siz=want.length();
char sw;
bool can=true;
int nub=0;
for(int i=0;i<siz;i++)
{
if(want[i]!=s[i])
{
nub++;
if(i==siz-1)
can=false;
for(int j=i+1;j<siz;j++)
{
if(s[j]==want[i])
{
sw=s[j];
s[j]=s[i];
s[i]=sw;
break;
}
if(j==siz-1)
{
can=false;
break;
}
}
}
if(can==false)
break;
}
if(can==false)
cout<<"Cannot transform to "<<want<<"\n";
else
cout<<nub<<"\n";
}
}