Input File: snapin.txt
Output File: snapout.txt
Time Limit: 1 second
Have you ever heard of Melodramia, my friend? It is a land of magic forests and mysterious swamps, of sprinting heroines and dashing heroes. And it is home to two dragons, Rose and Scarlet, who, despite their competitive streak, are the best of friends.
Rose and Scarlet love playing snap tag, a game for two players on an grid. The game goes as follows:
Rose and Scarlet are both snap tag experts and always find a winning strategy if one exists. If it is not possible for either player to gain the upper hand, then the game goes on forever.
In this task, you are given the size of the grid and the starting locations of both dragons. You must write a program to determine how the game ends: Does Rose win? Does Scarlet win? Does the game go on forever?
The input file will contain six space separated integers on a single line, in the format: R C rROSE cROSE rSCARLET cSCARLET where:
Output should consist of a single upper-case word with no punctuation.
ROSE
.SCARLET
.DRAW
.Input File: chairsin.txt
Output File: chairsout.txt
Time Limit: 1 second
Congratulations, contest winner! As a prize for winning the Australian Image Opening Competition you and all your friends are invited to a private concert with the country's finest musical acts.
As luck would have it, it has rained on the morning of the concert. To make matters worse, the staff did a very rushed job drying the seats! Now it is up to you to decide how to seat everyone.
The seats are arranged in a single long line in front of the stage. In particular there are chairs in the line, and each seat is either wet or dry.
However, all is not lost. Out of the N friends you are bringing to the concert K of them are happy to sit on a wet chair. The other N-K of your friends insist on sitting on a dry chair.
Since this concert is best enjoyed with friends, you would also like your group to be seated as close together as possible so that the distance between the leftmost person and rightmost person is as small as possible. Output the smallest distance possible between the leftmost and rightmost friend at the concert.
Your task is to write a program that outputs this smallest possible distance.
The input file will have two lines. The first line of input contains 3 numbers: C N K.
The second line will have C letters on it, each of which will be either d
or w
. These letters represent the line of chairs at the concert, giving the order of dry and wet chairs. In particular d
is a dry chair, w
is a wet chair.
Output should be a single integer, the smallest distance possible between the leftmost and rightmost friend at the concert with no more than K of them sitting on wet chairs.
Input File: ruckusin.txt
Output File: ruckusout.txt
Time Limit: 1 second
It's that time of year again! The Annual Ruckus World Championships is fast approaching and you are absolutely determined to see Australia victorious. As the name implies, the goal of the competition is to be as loud and obnoxious as possible. Players compete in teams of at least M people (there is no upper limit on team sizes). To make sure teams don't mix, team members must hold hands with each other.
Of course, you've found that there is nothing more obnoxious than spoilt kindergarteners, so you've rounded up N of the loudest ones you could find. You were hoping to send as many teams as possible, but some of the children have already started holding hands with their friends. Being as stubborn as they are, you are finding it rather difficult to convince them to let go of each other, or even to hold hands with anyone else.
Now for any other person, the story would end here; you'd have to send whatever teams their 'friendships' have forged. However, being the social engineering master you are, you've brought K lollipops to use to bribe the children. You can pass a lollipop to the hand of a child, which will make them let go of the hand they are holding.
Using your K lollipops, what is the largest number of teams with at least M children you can form?
The first line of the input file will contain four space separated integers on a single line, in the format: N L K M.
The following L lines will each contain two integers, in the format: li ri. This indicates that the lith child's left hand is holding the rith child's right hand. The children are numbered from 1 to N. No one can hold their own hands.
Output should consist of a single integer: the maximum number of teams with at least M children you can form.
© 2024. All Rights Reserved. 沪ICP备2023009024号-1