Problem Solution

1 solutions

  • 0
    @ 2024-03-29 12:03:24

    Author Code (Kamonasish Roy) :

    #include<bits/stdc++.h>
    using namespace std;
    const long long M=2e5+10,MOD=2000000007;
    typedef long long ll;
    int main()
    {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int t=1;
    cin>>t;
    while(t--){
    string s;
    cin>>s;
    int p=0,q=0;
    for(char c: s)p+=(c=='p'),q+=(c=='q');
    if(p>q)cout<<"Roy\n";
    else if(q>p)cout<<"Mahfuj\n";
    else cout<<"Draw\n";
    }
    return 0;
    }

    Tester Code (Jahirul Islam Hridoy):

    void solve()
    {
    string s ; cin >> s ; map < char , int > mp ;
    for(auto it : s) mp[it]++ ;
    if(mp['p'] == mp['q']) cout << "Draw" << "\n" ;
    else if(mp['p'] > mp['q']) cout << "Roy" << "\n" ;
    else cout << "Mahfuj" <<"\n" ;
    }
    int main()
    {
    Heart
    int t ; cin >> t ; while(t--) solve() ;
    }

  • 1

Information

ID
1040
Difficulty
1
Category
Beginners Click to Show
Tags
(None)
# Submissions
66
Accepted
43
Accepted Ratio
65%
Uploaded By