ABCD

ABCD

#include<iostream>
#include<cstdio>
#include<queue>
#include<vector>

using namespace std;

int main()
{
                 
          int n;
          cin>>n;
          string name;
          cin>>name;
          char ans[2*n+1];int ct = 0;
          for(int i=0;i<2*n;i++)
          {
                    int yy[4] = {0};
                    yy[name[i]-'A']++;
                    i++;
                    yy[name[i]-'A']++;
                    int wait;int flag = 0;
                    for(int j=0;j<4;j++)
                    {
                              if(yy[j]==0 && i==1)
                              {
                                        cout<<char('A'+j);
                                        ans[ct++] = 'A'+j;         
                              }         
                              else if(yy[j]==0)
                              {
                                        if(ans[ct-1]==('A'+j) && flag==0){flag = 1;wait = j;goto ny;}
                                        if(flag==0)
                                        {
                                                  cout<<char('A'+j);         
                                                  ans[ct++] = 'A'+j;
                                        }
                                        else
                                             {     cout<<char('A'+j)<<char('A'+wait);
                                                  ans[ct++] = 'A'+j;
                                                  ans[ct++] = 'A'+wait;
                                           }
                                           ny:;
                              }         
                    }
                   // cout<<endl;
          }
          cout<<endl;
          //system("pause");
          return 0;
}



No comments:

Post a Comment