Untitled

 avatar
unknown
plain_text
a month ago
1.0 kB
9
Indexable
 // Thongriu
#include <bits/stdc++.h>
#define endl '\n'
#define maxn 100005
#define MOD 1000000007
#define TASK "bai1"
#define ll long long
using namespace std;
string xau,C,B,A = "";
int n,m;
string check(int beg1, int end1, int beg2, int end2) {
    int i = beg1, j = beg2,dem = 0;
    string A = "";
    while (i <= end1 && j <= end2) {
        if (xau[i] == xau[j])
            A += xau[j++]; else dem++;
        i++;
    }
    dem+= (end1 - i + 1);
    if (dem == 1 && j > end2) return A;
    return "-1";
}
int main()
{
    ios_base:: sync_with_stdio(0);
    cin.tie(nullptr);
    if(fopen(TASK".inp","r")){
        freopen(TASK".inp","r",stdin);
    }
    cin >> xau;
    n = xau.length();xau = " " + xau; m = n/2;
    B = check(1,m+1,m+2,n);
    C = check(m+1,n,1,m);
    if(C == "-1" && B == "-1") cout <<"No Solution"; else
        if(B != "-1"){
            if(C != "-1" && C != B) cout << "Multiple Solutions";
            else cout << B;
        } else cout << C;
}
Leave a Comment