oj mrJudge
Toggle navigation
  • Login
    • Forget Password
      Login
User Image

Hello, Stranger

Guest
  • Analysis Mode
  • Problems
    • All Problems
    • Latest Problems
  • Join Us Now
  • Registration
  • Contact Us
  • Infomation
  • About
    • Terms of Use
    • Technical Specifications
    • Credits

pingpong Batch , stdin/stdout

Registered Users Only

Please login to utilize this feature.

Do note that this website only supports submissions in C++.

pingpong.html

Problem Description

Rar the Cat and Potato are playing a table tennis match! After playing a long and arduous match, they can't decide who has won! OH NO! You, being the ultimate master, must now decide for them who has won.

A table tennis match is played in a series of games. To win a game, the following conditions must be met:

  1. The winner must get at least 11 points.
  2. The winner must win by at least 2 points.

At the end of each game, the score is then tabulated. The player that first wins 3 games will win the match.

You will be given a string containing a record of the winner of each point. For example, "RPPRPPPRRPPPPPRP" means that Rar the Cat has won the first point, Potato wins the next two points, Rar wins the next point, etc, etc. In this case, Potato wins the game.

Also, when one game ends, the next point would be from the next game. The input log will also be guranteed to be valid.

Your program must implement the following functions:
  1. string winner(string S), which returns "Rar" or "Potato" based on the match.

Input

Your function will be given a log of the match based on the description above.

Output

Your function must either return "Potato" or "Rar", depending on the victor of the match.

Limits

The length of the log will be at most 1000.

Sample Input 1

RPPRRPPRPRRPRPRPRPRRRPPRPPPRRPPPPPRPPPPRPRPRPPPRPPRPRPPRPPPRRPPPPPRRRP

Sample Output 1

Potato

Explaination for Sample 1

The first game is denoted by "RPPRRPPRPRRPRPRPRPRR". In this game, Rar the Cat wins by 11-9.
The second game is denoted by "RPPRPPPRRPPPPPRP". In this game, Potato wins by 5-11.
The third game is denoted by "PPPRPRPRPPPRPPRP". In this game, Potato again wins by 5-11.
The fourth game is denoted by "RPPRPPPRRPPPPPRRRP". In this game, Potato wins by 7-11.
Thus, overall, Potato wins Rar the Cat by 3 games to 1.

template.cpp

#include "pingpong.h"
using namespace std;

string winner(string S) {

}

Tags

Syntax

Subtasks and Limits

Subtask Score #TC Time Memory Scoring
11001001s64MBMinimum
2011s64MBMinimum

Attachments

Attachment Filesize Last Updated
compile_cpp.bat114B19 Jul 2017, 01:19:29
grader.cpp152B27 Jul 2013, 14:43:43
pingpong.h67B27 Jul 2013, 14:43:33
compile_cpp.sh122B19 Jul 2017, 01:19:42
ans.cpp73B27 Jul 2013, 14:43:39

Judge Compile Command

g++-8 grader.cpp ans.cpp -o pingpong -Wall -Wshadow -static -O2 -lm -m64 -s -w -std=gnu++17 -fmax-errors=512

Accepted Submissions

subIDUserTimeMax Time

Past Submissions

subIDUserTimeScore
mrJudge 09.05.20
Copyright © 2020 mrJudge. All rights reserved.