NBC002- Editorial

PROBLEM LINK:

Practice
Noob Coding Contest

Author: sourav472
Tester: sourav472
Editorialist: sourav472

DIFFICULTY:

Medium.

PREREQUISITES:

Algorithm based (map hashing).

EXPLANATION:

For each String S1 & S2 count the maximum occurrence of a lower case alphabet without last character. And check the last character of each string , if last
charater is ‘e’ then “east” or ‘n’ then “north” or ‘s’ then “south” or ‘w’ then “west”.

SOLUTIONS:

Setter's Solution & Tester's Solution
#include <bits/stdc++.h>
using namespace std;
#define ll long long 
#define ull unsigned long long
#define rep(i,n) for(ll i=0;i<n;i++)
#define dfor(i,a,b) for(ll i=(a);i<(b);i++)
#define rfor(i,a,b) for(ll i=(a);i>=(b);i--)
#define pii pair<ll,ll>
#define vi vector<ll>
#define vpii vector<pii>
#define pb push_back
#define mp make_pair
#define ss second
#define ff first
#define fast ios_base::sync_with_stdio( false );cin.tie(NULL);
const ll mod = (ll)(1e9+7);

int main(){
fast
ll t;
cin>>t;
while(t--)
  {
      string s1,s2;
      cin>>s1>>s2;
      std::map<char,ll>mp1,mp2 ;
      for(int i=0;i<s1.length()-1;i++)
       mp1[s1[i]]++;
      for(int i=0;i<s2.length()-1;i++)
       mp2[s2[i]]++;
      ll max1 = 0, max2 = 0;
      for(auto op:mp1)
      {
          if(op.second > max1)
           max1 = op.second;
      }
      for(auto op:mp2)
      {
          if(op.second > max2)
           max2 = op.second;
      }
      char p,q;
      p = s1[s1.length()-1];
      q = s2[s2.length()-1];
      cout<<max1<<" ";
      if(p=='n')
      cout<<"north";
      else if(p=='s')
      cout<<"south";
      else if(p=='w')
      cout<<"west";
      else if(p=='e')
      cout<<"east";
      
      cout<<" "<<max2<<" ";
      
      if(q=='n')
      cout<<"north";
      else if(q=='s')
      cout<<"south";
      else if(q=='w')
      cout<<"west";
      else if(q=='e')
      cout<<"east";
      
      cout<<"\n";
      
  }
 
return 0;
}