-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path1156B.cpp
106 lines (81 loc) · 2.2 KB
/
1156B.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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
#include<bits/stdc++.h>
using namespace std;
int main()
{
int test;
char s[102];
cin >> test;
for(int i=0; i<test; i++)
{
scanf("%s",s);
int len = strlen(s);
if(len==1)
{
printf("%s\n",s);
}
else
{
int count = 0;
for(int j=0; j<len; j++)
{
if(s[j]==s[j+1])
{
count++;
}
}
if(count==len)
{
printf("%s\n",s);
}
else
{
int flag = 0;
for(int j=0; j<len; j++)
{
if(s[j]==s[j+2])
{
// cout << s[j] << " " << s[j+2] << endl;
cout << "No Answer" << endl;
flag = 1;
break;
}
}
if(flag==0)
{
int check = 0;
for(int i=0; i<len; i++)
{
if(((s[i+1]-'0')-(s[i]-'0'))==1)
{
check = 1;
}
else
{
check = 0;
break;
}
}
if(check==0)
{
cout << "asd" << endl;
printf("%s\n",s);
}
else
{
string s1,s2;
for(int k=0; k<len; k+=2)
{
s1.push_back(s[k]);
}
for(int k=1; k<len; k+=2)
{
s2.push_back(s[k]);
}
cout << s2 + s1 << endl;
}
}
}
}
}
return 0;
}