stanford proco 2014 may 18, 2014 nov a a dire warning (page 1 … · 2019. 9. 24. · stanford...

15
Stanford ProCo 2014 May 18, 2014 Nov A A Dire Warning (page 1 of 1) Overview: Print out “They’re taking the hobbits to Isengard!” Description: Oh no! Legolas is in dire straits, and sadly, this time his bow and arrow can’t save him. You see, while searching for Frodo, his good friends Merry and Pippin have been taken away as hostages to Isengard, home base for evil wizard Saruman the White. Legolas needs to inform Aragorn immediately. At first, he tried uploading this important message as a video to Youtube, but...let’s just say that things didn’t work out exactly the way he wanted. You, my friend, are his last remaining hope. Please print “They’re taking the hobbits to Isengard!” as quickly as possible. The hobbits’ fates depend on you! Filename: novA.{java, cpp, c, cc, py} Input: No input! Output: One line containing “They’re taking the hobbits to Isengard!” (without the quotes) Sample Output: They're taking the hobbits to Isengard!

Upload: others

Post on 14-Mar-2021

2 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Stanford ProCo 2014 May 18, 2014 Nov A A Dire Warning (page 1 … · 2019. 9. 24. · Stanford ProCo 2014 May 18, 2014 Nov B Prime Evil (page 1 of 1) Overview: Find the nth prime

Stanford ProCo 2014 May 18, 2014

Nov A A Dire Warning (page 1 of 1)

Overview: Print out “They’re taking the hobbits to Isengard!”

Description: Oh no! Legolas is in dire straits, and sadly, this time his bow and arrow can’t save him. You

see, while searching for Frodo, his good friends Merry and Pippin have been taken away as

hostages to Isengard, home base for evil wizard Saruman the White. Legolas needs to

inform Aragorn immediately. At first, he tried uploading this important message as a video to

Youtube, but...let’s just say that things didn’t work out exactly the way he wanted. You, my

friend, are his last remaining hope. Please print “They’re taking the hobbits to Isengard!” as

quickly as possible. The hobbits’ fates depend on you!

Filename: novA.java, cpp, c, cc, py

Input: No input!

Output: One line containing “They’re taking the hobbits to Isengard!” (without the quotes)

Sample

Output:

They're taking the hobbits to Isengard!

Page 2: Stanford ProCo 2014 May 18, 2014 Nov A A Dire Warning (page 1 … · 2019. 9. 24. · Stanford ProCo 2014 May 18, 2014 Nov B Prime Evil (page 1 of 1) Overview: Find the nth prime

Stanford ProCo 2014 May 18, 2014 Nov B Prime Evil (page 1 of 1)

Overview: Find the nth prime number. Description: Sauron is facing a slight problem. As it turns out, he recently learned that while he may be

considered the resident bad guy on Middle Earth, his reputation isn’t as solid anywhere else! Take the demon lords controlling the Diablo universe, for example. They don’t consider Sauron to be a Greater Evil, let alone a Prime Evil. After all, Sauron isn’t really capable of doing anything besides generating some minions every once in a while and dropping some legendary rings as loot. Nothing special. To fix this problem, Sauron is filling out an application to become the nth Prime Evil. Unfortunately, in order to successfully submit his application, he needs the application number, which happens to be the nth prime number. A positive integer p is a prime number if its only divisors are 1 and p. Using this definition, the nth prime number is the smallest positive integer that is not divisible by any of the first n-­1 prime numbers. The first prime number is 2. Given this information, can you help Sauron determine his application number? His reputation is at stake!

Filename: novB.java, cpp, c, cc, py Input: The input will contain a single positive integer n. Output: Output one line containing only the nth prime number. Assumptions: 1 ≤ n ≤ 1000 Sample Input #1:

1

Sample Output #1:

2

Sample Input #2:

20

Sample Output #2:

71

Page 3: Stanford ProCo 2014 May 18, 2014 Nov A A Dire Warning (page 1 … · 2019. 9. 24. · Stanford ProCo 2014 May 18, 2014 Nov B Prime Evil (page 1 of 1) Overview: Find the nth prime

Stanford ProCo 2014 May 18, 2014 Nov C Escaping Nazgul and Ampersands (page 1 of 1)

Overview: Replace all instances of the character ‘&’ in a given string with the string “&;” Description: The Fellowship of the Ring hasn’t had much success fleeing from the fearsome Nazgul

lately. The Nazgul, it seems, are expert stalkers, capable of finding the nine members of the fellowship across all sorts of beautiful valleys and peaceful forests. Fortunately, Arwen has a plan. You see, the Nazgul process all visual input via HTML string, but as creatures whose vision has been warped and twisted by Sauron’s evil powers, they are unable to process properly escaped HTML strings. Arwen knows this. She suspects that if every instance of a single ampersand character ‘&’ is replaced with the properly escaped string “&;” the Nazgul will be unable to comprehend the holy powers of the escaped ampersand and disappear…as if washed away by a mighty river or something. Can you help her defeat the Nazgul?

Filename: novC.java, cpp, c, cc, py Input: The input will contain exactly one line with the string to be escaped. Output: The given string with all of its ‘&’ characters escaped. Assumptions: 1 ≤ length of the string ≤ 1000

The string contains no leading or trailing whitespace. Sample Input #1:

Escaping Nazgul & Ampersands

Sample Output #1:

Escaping Nazgul &; Ampersands

Sample Input #2:

&&&;

Sample Output #2:

&;&;&;amp;;

Page 4: Stanford ProCo 2014 May 18, 2014 Nov A A Dire Warning (page 1 … · 2019. 9. 24. · Stanford ProCo 2014 May 18, 2014 Nov B Prime Evil (page 1 of 1) Overview: Find the nth prime

Stanford ProCo 2014 May 18, 2014

Nov D Triangular Abyss (page 1 of 1)

Overview: Print a triangle using the characters ‘x’ and ‘.’

Description: The dwarves are currently in the process of designing the Mines of Moria. To increase the

fame and renown of the mines, the dwarves would like to include a vast abyss, through

which Balrogs and the like shall not pass. To construct this abyss, they first need to map

out the specifications. Can you help them with this task?

The abyss specification will be n characters wide, where n is an odd integer. The abyss is

(n+1)/2 lines tall, and follows this format:

Line 1: 2 ‘x’s separated by n-­2 ‘.’s …

Line i: 2i ‘x’s separated by n-­2i ’.’s …

Line (n+1)/2: n ‘x’s

When all is said and done, the abyss should resemble an intimidating triangle of ‘.’s within

‘x’s. Good luck!

Filename: novD.java, cpp, c, cc, py

Input: The input will contain a single positive integer n

Output: The output should consist of (n+1)/2 lines of n characters each as described above.

Assumptions: 3 ≤ n ≤ 101 n is odd

Sample

Input #1:

3

Sample

Output #1:

x.x xxx

Sample

Input #2:

7

Sample

Output #2:

x.....x xx...xx xxx.xxx xxxxxxx

Page 5: Stanford ProCo 2014 May 18, 2014 Nov A A Dire Warning (page 1 … · 2019. 9. 24. · Stanford ProCo 2014 May 18, 2014 Nov B Prime Evil (page 1 of 1) Overview: Find the nth prime

Stanford ProCo 2014 May 18, 2014

Nov E Deciphering Silverware (page 1 of 1)

Overview: Given a string encrypted with a box cipher, decrypt the string.

Description: Emergency! Before embarking on the journey of a lifetime, Frodo hid all the silverware

residing at Bag End, so that his enterprising relatives wouldn’t make off with the goods. You

see, some of the other Baggins’ had designs on that silverware, and while Frodo wasn’t

super attached, he’d never really liked his relatives much for making fun of his hairy feet

(pot calling kettle black much?).

Frodo, however, does not have the best memory. Fortunately, he came up with a clever

solution. Before he left, he wrote down a message to himself with the location where he hid

all the silverware. Of course, he made sure to encrypt his message with a flawless cipher

strategy, making it impossible for anyone else to steal his silverware! But now that he’s

back, he wants to host a dinner party with Gandalf, and he really needs that message to be

decrypted so he can find his silverware again.

The encrypted message Frodo wrote can be conveniently expressed as a string s that has

n×m characters. It is possible to decrypt this silverware string if we arrange all of the

characters in a box with n rows and m columns. The characters should be ordered top to

bottom, left to right (so the first n characters of s should be placed in the first column). By

then reading the characters left to right, and then top to bottom (so the top row corresponds

to the first m characters), it’s possible to decrypt the encrypted string and recover the

valuable silverware! (See below for an example.) Can you help Frodo ensure that his dinner

party is a raging success?

Filename: novE.java, cpp, c, cc, py

Input: The input will consist of two lines of input.

The first line will contain n and m, separated by a space The second line will contain the encrypted string s with mn characters

Output: A single string, the decrypted form of string s

Assumptions: 1 ≤ n×m ≤ 100,000 m and n are positive integers. The string s will consist of only lowercase alphabetic characters

Sample

Input #1:

4 3 hlifeorflgae

Sample

Output #1:

hellogiraffe

Sample

Output #1

Comments:

Constructing 4x3 box as described above with the input string hlifeorflgae gives us: hel log ira ffe Reading the characters in the box left to right, top to bottom, gives us the decrypted string

hellogiraffe.

Page 6: Stanford ProCo 2014 May 18, 2014 Nov A A Dire Warning (page 1 … · 2019. 9. 24. · Stanford ProCo 2014 May 18, 2014 Nov B Prime Evil (page 1 of 1) Overview: Find the nth prime

Stanford ProCo 2014 May 18, 2014 Nov F Shopping For Dwarves (page 1 of 1)

Overview: Given a limited budget and some items, find the maximum utility that can be purchased. Description: The hospitable Bard is shopping in the market at Laketown for some supplies for his guests,

the dwarves. These dwarves are rather demanding when it comes to food, so Bard must choose wisely when it comes to his shopping list. Thankfully, they have provided him with the foods that they enjoy the most, along with their price. Now, Bard just needs to find the right combination of foods within his budget that will make his guests happiest. Can you help him with his important task? Bard shares with you a list of n items and a budget of b dollars. Each item has a price p and dwarf utility u. He may purchase fractional amounts of each item, but not more than one of any particular item. A fraction f of an item has a price p×f and utility u×f. Help Bard come up with a shopping list of (possibly fractions of) items that have the maximum utility for the dwarves without exceeding the budget of b dollars.

Filename: novF.java, cpp, c, cc, py Input: The input will contain exactly n+2 lines.

The first line contains b, the budget in dollars. The second line contains n, the total number of items for sale. The third line to the (n+2)th lines each contain space separated numbers p u representing the price and utility of one of the n items.

Output: One line containing the maximum total utility found. Print the utility rounded exactly to six

decimal places. Assumptions: 1 ≤ n ≤ 100,000

0 ≤ b ≤ 1,000,000,000 0 ≤ p, u ≤ 1,000 All floating point numbers in the input will be given to exactly two decimal places.

Sample Input #1:

2.50 3 2.00 1.00 0.50 2.00 6.00 2.50

Sample Output #1:

3.000000

Sample Input #2:

4.00 4 1.00 2.00 5.00 2.50 2.00 1.20 3.00 1.00

Sample Output #2:

3.700000

Page 7: Stanford ProCo 2014 May 18, 2014 Nov A A Dire Warning (page 1 … · 2019. 9. 24. · Stanford ProCo 2014 May 18, 2014 Nov B Prime Evil (page 1 of 1) Overview: Find the nth prime

Stanford ProCo 2014 May 18, 2014

Nov G Runic Evaluation (page 1 of 1)

Overview: Evaluate an arithmetic expression of rational numbers.

Description: Elrond, Lord of Rivendell, has been asked to decode some ancient mystical runes for his

adventuring friends again! To be honest, he’s not too keen on helping them, considering

how much fun they make of his vegetarian habits… but hey, that’s what friends do, right?

These runes are like none other that Elrond has ever seen. The sequence of runes is an

arithmetic expression consisting of adding and subtracting rational numbers. Despite being

practically immortal, Elrond has never encountered such runes before. All he knows is that

to decode the runes, the arithmetic expression must be evaluated, but he has no idea how

to do so. Can you help him?

Filename: novG.java, cpp, c, cc, py

Input: The rational numbers are comprised of two positive integers (the numerator and the

denominator, in that order), separated by a forward slash. Adjacent rational numbers will be

separated by an operator (‘+’ or ‘-­’). There will be exactly one operator between each pair of

adjacent rational numbers, and no other operators (in particular, no leading ‘+’ or ‘-­’). In a

monumental waste of quality parchment, all of the integers, slashes, and operators will be

space-­separated.

Output: One line containing the result of decoding the runic sequence. The result should be in the

form of a / b where a is a (possibly negative) integer and b is a positive integer. The integer

a and b should not share any common factors greater than 1. If the arithmetic expression

evaluates to 0, output “0 / 1”. Print a, the slash, and b space-­separated.

Assumptions: The input expression/rune sequence will contain ≤ 100,000 characters.

Every numerator and denominator will be a positive integer that is at most 10.

Sample

Input #1:

10 / 3 + 5 / 2 -­ 4 / 2 -­ 1 / 2 + 4 / 6

Sample

Output #1:

4 / 1

Sample

Input #2:

1 / 1 -­ 2 / 1

Sample

Output #2:

-­1 / 1

Page 8: Stanford ProCo 2014 May 18, 2014 Nov A A Dire Warning (page 1 … · 2019. 9. 24. · Stanford ProCo 2014 May 18, 2014 Nov B Prime Evil (page 1 of 1) Overview: Find the nth prime

Stanford ProCo 2014 May 18, 2014 Nov H Happy Birthday Happy Birthday (page 1 of 1)

Overview: Find the minimum number of people in the room such that the probability of at least two people in the room having the same birthday is at least a certain percentage.

Description: Hobbits are well known for their love of celebrations, as was indicated by Bilbo’s farewell

extravaganza, complete with live dragon fireworks. What’s more, the party celebrated not only Bilbo’s 111th birthday, but Frodo’s also 33rd birthday as well, for why celebrate one birthday when you can celebrate two! In fact, hobbits love double birthdays so much that they want to form an entire system of communities around celebrating double birthdays. Each community will be set a threshold probability p, which is the probability that at least two people in the community share the same birthday. The higher the threshold, the more festive the community. However, in the interest of avoiding overcrowding, they would like to know the minimum number of people required in a community to achieve the desired threshold p. Can you help? You are given a probability p. Taking the assumption that there are 366 possible birthdays and each birthday is equally likely, find the smallest number of people in the room such that the probability that at least two people in the room share the same birthday is at least p.

Filename: novH.java, cpp, c, cc, py Input: The input will be exactly one line containing a number p. p will consist of '0.' followed by

exactly 4 decimal digits. Output: The minimum number of people in the room such that the problem conditions are satisfied. Assumptions: 0.0001 ≤ p ≤ 0.9995

p is selected such that given that the answer is N, the probability that at least two of the N people share a birthday differs from p by at least 10-­4.

Sample Input #1:

0.5000

Sample Output #1:

23

Sample Input #2:

0.9995

Sample Output #2:

73

Page 9: Stanford ProCo 2014 May 18, 2014 Nov A A Dire Warning (page 1 … · 2019. 9. 24. · Stanford ProCo 2014 May 18, 2014 Nov B Prime Evil (page 1 of 1) Overview: Find the nth prime

Stanford ProCo 2014 May 18, 2014 Nov I Smaug’s Maze (page 1 of 2)

Overview: Find the shortest route to escape a maze. Description: Bilbo has found the Arkenstone in the massive treasure room! However, his elation is

short-­lived when he discovers that Smaug, in his infinite boredom, has created a maze out of the treasure, and Bilbo must traverse the maze in order to get out. He only has so much time before Smaug tracks him down, and the dragon is getting ever closer… THUD… THUD…

THUD… Can you help him survive Smaug’s Maze? You are given a map of the maze with n rows and m columns in the form of a grid of characters.

‘S’ represents Bilbo’s starting point. ‘.’ represents a traversable space. ‘#’ represents an impassable wall of treasure.

Bilbo must start at the specified location. Each step, he can move from his current location to an adjacent traversable space (horizontally, vertically or diagonally). He wants to escape the maze by reaching the edge of the maze, and then stepping out of the maze. Write a program that prints out for Bilbo the length of the shortest escape route from the maze. If there is no way to escape the maze, your program should print “NO ESCAPE!” instead and wish Bilbo the best of luck!

Filename: novI.java, cpp, c, cc, py Input: The input consists of exactly n+1 lines.

The first line of the input will contain two space separated integers n m. The integers n and m specify the number of rows and columns of the maze, respectively. The next n lines each containm characters specifying the map of the maze. Each character specifies a tile in the maze, as described above.

Output: If an escape route exists, output the length in steps of the shortest escape route. If no

escape route exists, output the string “NO ESCAPE!”. Assumptions: 1 ≤ n,m ≤ 1000

The character ‘S’ will appear exactly once in the maze. Sample Input #1:

3 3

###

#S#

.#.

Sample Output #1:

2

Sample Input #2:

3 3

###

#S#

###

Page 10: Stanford ProCo 2014 May 18, 2014 Nov A A Dire Warning (page 1 … · 2019. 9. 24. · Stanford ProCo 2014 May 18, 2014 Nov B Prime Evil (page 1 of 1) Overview: Find the nth prime

Stanford ProCo 2014 May 18, 2014 Nov I Smaug’s Maze (page 2 of 2)

Sample Output #2:

NO ESCAPE!

Sample Input #3:

7 12

.###########

#.#########.

#.S........#

#.#######.##

#...........

#.#########.

#.#########.

Sample Output #3:

3

Page 11: Stanford ProCo 2014 May 18, 2014 Nov A A Dire Warning (page 1 … · 2019. 9. 24. · Stanford ProCo 2014 May 18, 2014 Nov B Prime Evil (page 1 of 1) Overview: Find the nth prime

Stanford ProCo 2014 May 18, 2014 Nov J Food Coma (page 1 of 2)

Overview: Determine the location and direction of dwarves after a certain time Description: As mentioned before, dwarves love to eat as much as hobbits love to party. Thorin’s

company has eaten plenty at Bilbo’s house and a food coma is coming over them all. They are beginning to stumble about aimlessly, bouncing off of each other when they collide, wandering about the house and out into the streets. Gandalf saunters in at this moment and sees all the dwarves meandering about rather foolishly and must gather them all together to deliver his news. He needs your help to find all of the dwarves. You are given n dwarves, and for simplicity’s sake, let us assume they only move about on the x-­axis. The dwarves are numbered 1 to n from left (lowest x-­value) to right (highest x-­value). You are given the locations of all of the dwarves on the x-­axis, and the directions in which they are moving (negative or positive x-­direction). All dwarves move at the same speed of 1 unit per second. When dwarves collide, they bounce off of each other, reversing their directions while still travelling at the same speed. You are to determine the locations of all the dwarves and the direction in which they are moving after t seconds.

Filename: novJ.java, cpp, c, cc, py Input: The input will consist of exactly n+1 lines.

The first line contains two space separated integers n t, denoting the number of dwarves and the number of seconds respectively. The next n lines will each contain an integer and a character separated by a space, denoting the position of a dwarf on the x-­axis and the direction he or she is moving. Line i (2 ≤ i ≤ n+1) will contain the information for dwarf numbered i-­1. The character will be either ‘+’ or ‘-­’ . A ‘+’ means the dwarf is moving in the positive x-­direction while a ‘-­’ means the dwarf is moving in the negative x-­direction.

Output: The output consists of n lines. The ith line should contain the location of dwarf i after t

seconds, and the direction it is moving in. If it is moving in negative x-­direction, output ‘+’. Otherwise, output ‘-­’. If dwarf i is involved in a collision during the tth second, output the direction they face before the collision has taken place. Refer to the sample testcases for more details.

Assumptions: 1 ≤ n ≤ 100,000

1 ≤ t ≤ 1,000,000,000 All dwarves start with an x-­coordinate at least 0 and at most 1,000,000,000. You can assume that no two dwarves have the same initial x-­coordinate. Also, the x-­coordinates will be given in ascending order (i.e. if i < j, then dwarf i will have a smaller x-­coordinate than dwarf j).

Page 12: Stanford ProCo 2014 May 18, 2014 Nov A A Dire Warning (page 1 … · 2019. 9. 24. · Stanford ProCo 2014 May 18, 2014 Nov B Prime Evil (page 1 of 1) Overview: Find the nth prime

Stanford ProCo 2014 May 18, 2014 Nov J Food Coma (page 2 of 2)

Sample Input #1:

5 3 0 + 6 -­ 7 + 10 -­ 11 -­

Sample Output #1:

3 + 3 -­ 7 -­ 8 -­ 10 +

Sample Output #1 Comments

Note that dwarf 1 is moving in positive x-­direction before the collision at the tth second and dwarf 2 is moving in negative x-­direction before the collision at the tth second.

Page 13: Stanford ProCo 2014 May 18, 2014 Nov A A Dire Warning (page 1 … · 2019. 9. 24. · Stanford ProCo 2014 May 18, 2014 Nov B Prime Evil (page 1 of 1) Overview: Find the nth prime

Stanford ProCo 2014 May 18, 2014 Nov K Shooting Spiders (page 1 of 1)

Overview: Find the minimum number of range decrements required to zero a given array. Description: Travelling through Mirkwood, Tauriel and Legolas decide to have a shooting match in which

they see who can shoot down more spiders with fewer bow releases. The spiders are advancing rather peculiarly in columns of varying depth. Being talented archers, both can release several arrows at once and shoot down a contiguous series of spiders. However, they are not so talented that they can skip over a spider in a series to shoot its neighbor. Having made a good sport of these devilish spiders, Tauriel and Legolas now want to take the challenge one step further: to take down all the spiders using the least number of bow releases possible. However, they need help determining exactly what that number is. You will be given an array of n positive integers, representing the number of spiders in each column. In a single release of a bow, you are allowed to shoot at a range of columns and eliminate one spider in each. However, you are only allowed to do this if there is a spider in each of those columns. In other words, in each step, you can pick any two indices in the array such that every integer in between (inclusive) is positive, and decrement all of those integers. Find the minimum number of bow releases required to shoot down all the spiders, i.e. decrement the entire array to zero.

Filename: novK.java, cpp, c, cc, py Input: The input consists of exactly 2 lines

The first line contains the number of columns n The second line will contain n space separated integers: the number of spiders in each column.

Output: Output the minimum number of steps to shoot down all the spiders. Assumptions: 1 ≤ n ≤ 100,000

Each column has a positive number of spiders no greater than 1,000,000. Sample Input #1:

10 1 2 3 2 4 5 1 2 4 3

Sample Output #1:

9

Sample Input #2:

10 10 20 30 40 50 40 30 20 10 1

Sample Output #2:

50

Page 14: Stanford ProCo 2014 May 18, 2014 Nov A A Dire Warning (page 1 … · 2019. 9. 24. · Stanford ProCo 2014 May 18, 2014 Nov B Prime Evil (page 1 of 1) Overview: Find the nth prime

Stanford ProCo 2014 May 18, 2014 Nov L Cliquey Friends (page 1 of 2)

Overview: Find a clique in a graph of a given size Description: Aragorn, son of Arathorn, is convinced that some of his friends are becoming too cliquey

and exclusionary. To prove it to them via inspiring speech (on horseback), he is determined to find a k-­clique among the interaction network of his friends. Aragorn, son of Arathorn has n friends, labeled 1 to n. Two friends are called connected if they have conversed about anything (Mordor, Frodo, the shower situation) in the last day. A k-­clique in this network is defined as k friends that are all connected to each other (i.e. every pair of them is connected). Armed with futuristic magical spells, Aragorn can pick any group of his friends and learn whether or not there are k friends among them that form a k-­clique. But he doesn't learn the k-­clique itself. He wishes to enlist your help in finding a k-­clique among his friends. You are absolutely certain that there is indeed a k-­clique in Aragorn’s friend interaction network. You will be given n and k. You can use the magical spell to learn whether some subset of the n friends includes a k-­clique, but you can do so at most 150 times. Will you be able to find a list of k friends that are a k-­clique and help bolster Aragorn’s speech?

Filename: novL.java, cpp, c, cc, py Input/Output: This is an interactive problem. This means that your program will receive input based on the

output your program produces. When your program starts, you will be provided two space-­separated integers n and k as specified above. Your program may then do the following up to 150 times:

Output between 1 and n unique space separated integers vi (1 ≤ vi ≤ n) representing the set of friends you want to give to our "magic spell." Your program will be provided with a line of input: either “YES” or “NO”, indicating whether or not the given set of friends contains a k-­clique.

Your program must then finish by producing the following output. Output the k-­clique. Output the string “CLIQUE: “ followed by k space separated

integers representing the k-­clique. You MUST output a newline character and flush the output stream after each output:

In C, use printf("\n");; fflush(stdout);; In C++, use cout << "\n" << flush;; or cout << endl;; In Java, use System.out.println();; System.out.flush();; In Python, use print and sys.stdout.flush()

Assumptions: 1 ≤ k ≤ n ≤ 100 Sample Sequence #1:

COMPUTER 5 3

YOU 1 2 3

COMPUTER NO

YOU 1 2 4

Page 15: Stanford ProCo 2014 May 18, 2014 Nov A A Dire Warning (page 1 … · 2019. 9. 24. · Stanford ProCo 2014 May 18, 2014 Nov B Prime Evil (page 1 of 1) Overview: Find the nth prime

Stanford ProCo 2014 May 18, 2014 Nov L Cliquey Friends (page 2 of 2)

COMPUTER NO

YOU 1 2 5

COMPUTER NO

YOU 1 3 4

COMPUTER NO

YOU 1 3 5

COMPUTER YES

YOU CLIQUE: 1 3 5 Sample Sequence #2:

COMPUTER 5 3

YOU 1 2 3 4 5

COMPUTER YES

YOU 1 3 4 5

COMPUTER YES

YOU 1 3 5

COMPUTER YES

YOU CLIQUE: 1 3 5