-
Notifications
You must be signed in to change notification settings - Fork 13
/
ABCD.cpp
75 lines (51 loc) · 1.42 KB
/
ABCD.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
#include<iostream>
#include<stdio.h>
#include<string.h>
using namespace std;
int main()
{
int n;
scanf("%d",&n);
char a[2][2*n];
for(int i=0;i<2*n;i++)
{
cin>>a[0][i];
}
int count[4]={0};
count[(int)a[0][0]-65]=1;
count[(int)a[0][1]-65]=1;
for(int i=0,j=0;i<4;i++)
{
if(count[i]==0)
{
a[1][j]=(char)(i+65);
j++;
}
}
//cout<<a[1][0]<<a[1][1]<<endl;
for(int k=2;k<2*n;k=k+2)
{
memset(count,0,sizeof(count));
count[(int)a[0][k]-65]=1;
count[(int)a[0][k+1]-65]=1;
for(int i=0,j=0;i<4 && j<2;i++)
{
if(count[i]==0)
{
a[1][k+j]=(char)(i+65);
j++;
}
}
if(a[1][k-1]==a[1][k])
{
char temp=a[1][k];
a[1][k]=a[1][k+1];
a[1][k+1]=temp;
}
}
for(int i=0;i<2*n;i++)
cout<<a[1][i];
cout<<endl;
system ("pause");
return 0;
}