/ SeriousOJ /

Record Detail

Accepted


  
# Status Time Cost Memory Cost
#1 Accepted 0ms 284.0 KiB
#2 Accepted 0ms 284.0 KiB
#3 Accepted 0ms 404.0 KiB

Code

#include <stdio.h>
#include <string.h>

// Function to determine the winner of the game
char* determineWinner(char* S) {
    int p_count = 0, q_count = 0;
    
    // Count the occurrences of 'p' and 'q' in the string
    for (int i = 0; S[i] != '\0'; i++) {
        if (S[i] == 'p')
            p_count++;
        else if (S[i] == 'q')
            q_count++;
    }
    
    // Determine the winner based on the counts
    if (p_count > q_count)
        return "Roy";
    else if (q_count > p_count)
        return "Mahfuj";
    else
        return "Draw";
}

int main() {
    int T;
    scanf("%d", &T);

    while (T--) {
        char S[101];
        scanf("%s", S);
        printf("%s\n", determineWinner(S));
    }

    return 0;
}

Information

Submit By
Type
Submission
Problem
P1040 Character game
Contest
TLE_Headquarters - round #1
Language
C99 (GCC 13.2.0)
Submit At
2024-03-27 16:11:59
Judged At
2024-03-27 16:11:59
Judged By
Score
100
Total Time
0ms
Peak Memory
404.0 KiB