0% found this document useful (0 votes)
27 views2 pages

Max Point Difference in Card Game

Uploaded by

vinhtienolympia
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
27 views2 pages

Max Point Difference in Card Game

Uploaded by

vinhtienolympia
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

ICPC UMT 2024 Problems

Problem A
Advantage
time limit per test: 1 second
memory limit per test: 256 megabytes

Luna and Tina are two final-year IT students at UMT University. In their free time, they came
up with the idea of creating a game that simulates the familiar rock-paper-scissors game. This
is a strategic game where two players compete against each other using a special deck of cards.
The deck consists of 2n cards, divided into three types: rock, paper, and scissors.

Each player is dealt n cards, and the game proceeds as follows:


• The game consists of n rounds, and in each round, both players will choose a card from
their hand and compare them according to the rules: rock beats scissors, scissors beats
paper, and paper beats rock.
• After comparison, if the two cards are equal, neither player scores a point. If one card
wins, that player scores 1 point.
• The used card cannot be used again in subsequent rounds.
After developing the game, Luna and Tina decided to test it to find any bugs before release.
During the testing, Luna accidentally discovered that he could see the card Tina would
choose in each round. Before informing Tina so they could fix the bug together, Luna wanted
to surprise Tina with his luck. Therefore, Luna secretly exploited this bug to achieve an
overwhelming victory over Tina.

Calculate the maximum point difference between Luna and Tina when the game ends.

Input
The first line is the integer n (1 ≤ n ≤ 106 ).

The second line contains n characters separated by spaces, representing Luna’s cards.

The third line contains n characters separated by spaces, representing Tina’s cards.

The second and third lines contain only the characters R, S, and P, corresponding to rock,
scissors, and paper, respectively.

Output
A single integer is the maximum point difference between Luna and Tina.

1
ICPC UMT 2024 Problems

Sample Input 1 Sample Output 1


3
RPS 0
PPP

Note
Luna’s optimal play strategy:

• Tina chooses the first card P, Luna will choose the card R. Luna loses, so Tina gets 1
point.

• Tina chooses the second card P, Luna will choose the card P. It’s a tie, so no one gets
any points.

• Tina chooses the last card P, Luna will choose the card S. Luna wins, so Luna gets 1
point.

Thus, the point difference is 1 − 1 = 0.

You might also like