C.最長の非共通サブシーケンス
トピックCへのリンク-最長の非共通サブシーケンスの問題を
解決するためのアイデア
彼らは最長必要とするため、非ので、同じ文字列であれば二つの出力、共通の配列を-1、2〜最長の文字列の長さのそれ以外の出力長
コードを添付
//#pragma GCC optimize("-Ofast","-funroll-all-loops")
#include<bits/stdc++.h>
#define int long long
#define lowbit(x) (x &(-x))
#define endl '\n'
using namespace std;
const int INF=0x3f3f3f3f;
const int dir[4][2]={-1,0,1,0,0,-1,0,1};
const double PI=acos(-1.0);
const double e=exp(1.0);
const double eps=1e-10;
const int M=1e9+7;
const int N=2e5+10;
typedef long long ll;
typedef pair<int,int> PII;
typedef unsigned long long ull;
string a,b;
signed main(){
ios::sync_with_stdio(false);
cin.tie(0);cout.tie(0);
cin>>a>>b;
if(a==b){
cout<<-1<<endl;
return 0;
}
cout<<max(a.size(),b.size())<<endl;
return 0;
}