Source Code
// {In the Name of Allah, the Most Beneficent, the Most Merciful }

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double dd;
#define mp make_pair
#define pb push_back
#define pf push_front
#define IOS ios_base::sync_with_stdio(0);cin.tie(NULL);
#define no cout<<"NO\n"
#define yes cout<<"YES\n"
#define el "\n"
int freq[27];

int main()
{
       /**/IOS/**/

      int t;
      cin>>t;

      int c=t-1;

      string s;
      char q='1',sh='A';
      while(t--)
      {
          cin>>s;

          if(c==t&&s[0]==sh)
          {

              cout<<"YES"<<endl;
              q=s[s.size()-1];
          }
          else if(c==t&&s[0]!=sh)
          {
              c--;
              sh=sh+1;
          }
          else if(q==s[0])
          {
              cout<<"YES"<<endl;
              q=s[s.size()-1];
          }
          else
          {
              cout<<"NO"<<endl;
          }
      }






}
Copy
Well-indexed? 332IQ
GNU G++17
22 ms
512 KB
Wrong Answer