-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathabcd.cpp
More file actions
49 lines (48 loc) · 675 Bytes
/
abcd.cpp
File metadata and controls
49 lines (48 loc) · 675 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
42
43
44
45
46
47
48
49
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <cstring>
#include <map>
#include <set>
using namespace std;
typedef long long int ll;
#define EOL '\0'
#define null '1'
int main()
{
ios_base::sync_with_stdio(false);
int n;
cin>>n;
string s;
char k[(2*n)+1];
cin>>s;
//memset(k,null,sizeof(k));
k[2*n]=EOL;
for(int i=0;i<2*n;i=i+2)
{
int p1=-1, p2=-1;
int a[4]={1,1,1,1};
a[s[i]-65]=0;
a[s[i+1]-65]=0;
for(int j=0;j<4;j++)
{
if(a[j]==1)
{
if(p1==-1) p1=j;
else p2=j;
}
}
if(k[i-1]==65+p1)
{
k[i]=65+p2;
k[i+1]=65+p1;
}
else
{
k[i]=65+p1;
k[i+1]=65+p2;
}
}
cout<<k;
}