-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path1.cpp
More file actions
41 lines (41 loc) · 824 Bytes
/
1.cpp
File metadata and controls
41 lines (41 loc) · 824 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
/********************
=====================
**Code By-hardikdua**
=====================
*********************/
#include<bits/stdc++.h>
#define inf 9999999999999999
#define speed(); ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
using namespace std;
typedef long long int ll;
int n;
string s;
int main()
{
speed();
cin>>s;
n=s.size();
int k=(n/2);
string l="";
int i;
for(i=0;i+1<k;i+=2)
{
char x=s[n-i-1];
char y=s[n-i-2];
if(s[i]==x)
l+=x;
else if(s[i+1]==x)
l+=x;
else if(s[i]==y)
l+=y;
else if(s[i+1]==y)
l+=y;
}
string ans=l;
if (i<k)
ans+=s[i];
reverse(l.begin(),l.end());
ans+=l;
cout<<ans;
return 0;
}