-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy patholliePS-21.cpp
63 lines (61 loc) · 1.3 KB
/
olliePS-21.cpp
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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
ll t;
cin>>t;
for(int k = 1 ; k<=t ; k++)
{
string str;
int n;
cin>>n;
for(int i = 1 ; i<=n-2 ; i++)
{
string s;
cin>>s;
str = str + s;
}
int i = 1 , j = 2;
int index1 , index2;
bool check = true;
while(j<=str.length()-1)
{
if(str[i] == str[j])
{
i = i+2;
j = j+2;
}
else if(str[i] != str[j])
{
index1 = i;
index2 = j;
check = false;
break;
}
}
if(check == false)
{
for(int i = 0 ; i<index1 ; i = i+2)
{
cout<<str[i];
}
cout<<str[index1];
for(int i = index2 ; i<=str.length()-2 ; i = i+2)
{
cout<<str[i];
}
cout<<str[str.length()-1];
cout<<endl;
}
else
{
for(int i = 0 ; i<=str.length()-2 ; i = i+2)
{
cout<<str[i];
}
cout<<str[str.length()-1]<<'a'<<endl;
}
}
return 0;
}