无限替换 - CodeForces 1674C - 虚拟裁判 (csgrandeur.cn)
题意:给你a串和b串,a串中每一个字符'a'可以换成b串(也可以不用换),问可以通过更换得到多少个不同的a串,如果可以得到无数个a串输出-1
没有注意到可以不用换的条件,wa了一次
code
#include<bits/stdc++.h>
#define x first
#define y second
#define mak make_pair
#define IOS ios::sync_with_stdio(false),cin.tie(0),cout.tie(0)
#define debug(a) cout<<a<<'\n'
#define endl '\n'
#define umap unordered_map
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
typedef pair<int,int> PII;
const int N=1e5+10,M=1,inf=0x3f3f3f3f,mod=1e9+7;
int t;
void solve()
{
string a,b;
cin>>a>>b;
bool ok=0;
for(int i=0;i<b.size();i++)
{
if(b[i]=='a')
{
ok=1;
break;
}
}
if(ok)
{
if(b.size()==1) cout<<1<<endl;
else cout<<-1<<endl;
return;
}
else
{
LL res=1;
int len=a.size();
while(len--)
{
res*=2;
}
cout<<res<<endl;
return;
}
}
int main()
{
IOS;
cin>>t;
while(t--)
{
solve();
}
return 0;
}