1239 - CS I2P (II) 2017 Lee Final Scoreboard

Time

2017/06/09 12:00:00 2017/06/09 15:30:00

Clarification

# Problem Asker Description Reply Replier Reply Time For all team

# Problem Pass Rate (passed user / total user)
10682 Parentheses Matching
11462 cppreference
11491 Josephus
11492 rotate
11493 Simply Fractions (multiplication)
11494 Set operations

10682 - Parentheses Matching   

Description

A string is said to be valid if it matches one of the following rules:

(1) The string is an empty string.

(2) If a string S is valid, then {S}, [S], (S) and <S> are valid.

(3) If strings S1 and S2 are both valid, then S1S2 is valid.

Given a string consisting of parentheses, determine if it is a valid string.

 

Input

The first line of the input contains an integer N (N ≤ 10000) denoting the number of test cases followed by. Each of the next N lines corresponds to a test case, which contains a string consisting of parentheses, and the maximum string length will be no more than 1000. Note that an empty string (a line which contains the newline character only) may be contained in the input and it should be considered as a valid string according to rule (1).

 

Case 1 : N≤50

Case 2: N≤100

Case 3: N≤1000

Case 4: N≤10000

Output

For each test case, print “Case i:” and then “Yes” or “No” to indicate that the string is valid or not, separated by a space character. i is the test case number starting from 1.

Sample Input  Download

Sample Output  Download

Tags

qq 好難 捨不得煥宗的課QQ



Discuss




11462 - cppreference   

Description

版本:

20180311

 

使用說明:

請下載code或header(兩個是同個檔案)

把附檔名從.cpp改成.zip

解壓縮後

reference>en>cpp.html

即可看到官方文件

Input

Output

Sample Input  Download

Sample Output  Download

Partial Judge Code

11462.cpp

Partial Judge Header

11462.h

Tags

CPP Reference



Discuss




11491 - Josephus   

Description

The Josephus problem is notoriously known. For those who are not familiar with the problem, among n people numbered 1, 2, . . . , n, standing in circle every mth is going to be executed and only the life of the last remaining person will be saved. Joseph was smart enough to choose the position of the last remaining person, thus saving his life to give the message about the incident.

 

Given a group of  n men arranged in a circle under the edict that every m man will be executed going around the circle until only one remains. Find the position in which you should stand in order to be the last survivor.

Input

Each line with 2 integers, n, m. n is the number of people. m is the number that every m person is executed. Input terminated by EOF.

Output

The output will consist in separate lines containing the position of the person which life will be savedEach line should be ended with a newline character '\n'.


Sample Input  Download

Sample Output  Download

Tags




Discuss




11492 - rotate   

Description

Given an integer sequence, say {0, 1, 2, 3, 4, 5}, we can rotate the sequence to right 1 time and generate a new sequence.

Try to generate all possible results for the original sequence, and print the result by the order they show up.

For the example above, the output would be :

5 0 1 2 3 4

4 5 0 1 2 3

3 4 5 0 1 2

2 3 4 5 0 1

1 2 3 4 5 0

0 1 2 3 4 5 (loop occuring, stop output result from this on.)

 

Input

An integer sequence, separated by spaces. End by EOF.

Output

List all possible unique results generated from original sequence by rotation and output them by the order they show up .

Each line contains one sequence, where there is a space between each number.

Note that there is a '\n' at the end of each line.

Sample Input  Download

Sample Output  Download

Tags




Discuss




11493 - Simply Fractions (multiplication)   

Description

Given several fractions, compute their product (multiplies all fractions) and express the answer in the simplest fraction form.

Input

There are many test cases in one subtask.

The first line of each test case contains an integer t, which indicates the number of fractions in the input. Each of the following t lines contains two integers a and b, which represent the numerator and the denominator of a fraction.

subtask 1 : t<=2. 1<=a,b<=10.
subtask 2 : t<=5. 1<=a,b<=10.
subtask 3 : t<=5. 1<=a,b<=50.
subtask 4 : t<=10. 1<=a,b<=100.

Output

Each test case outputs one line.

The output is the product reduced to the simplest fraction form. You need to print a '/' between the numerator and the denominator.

Sample Input  Download

Sample Output  Download

Tags




Discuss




11494 - Set operations   

Description

假設有A B C 3個set,range_diff A C的結果是

  • A與B做difference,得到D
  • 將D與C做difference,得到range_diff A C的結果

lower_bound and upper_bound can help you.

Input

How to compare the integer sequence (calculate the key of an integer sequence):

  • key=sum every elements in an integer sequence
  • if the length of a integer sequence is 0, the key is 0.
  • e.g., the key of an integer sequence "3 9 -1 3 -6" is 8 (3+9-1+3-6).

The input consist of series of command. Each commands is insert, range_diff, range_inter or range_out.

​insert: inserts an integer sequence (each value is greater than -11 and smaller than 11, stop reading from cin when value is 0). If a key has already existed, then replace it with the input sequence.

For example,

insert 3 9 -1 3 -6 0

The set should contain 3 9 -1 3 -6.

insert 2 2 -3 7 0

The set should contain 2 2 -3 7.

 

range_diff: calculates difference of all integer sequences from an integer (first key) to an integer (second key). Sort the result in ascending order. Output a space character (' ') after printing an integer. Output a newline character ('\n') after printing the difference. Note: What is the difference between set_difference and set_symmetric_difference? Warning: You must calculate from smaller key to bigger key.

For example,

insert 2 -5 -5 0

insert 3 -5 -5 -5 2 10 0

insert 2 10 3 -5 0

range_diff -8 9

It should output

-5 3 10 

For example,

insert 2 -5 -5 0

insert 3 -5 -5 -5 2 10 0

insert 2 10 3 -5 0

range_diff -8 16

It should output

For example,

insert 2 -5 -5 0

insert 3 -5 -5 -5 2 10 0

insert 2 10 3 -5 0

range_diff -5 16

It should output

-5 -5 

 

range_inter: calculates intersection of all integer sequences from an integer (first key) to an integer (second key). Sort the result in ascending order. Output a space character (' ') after printing an integer. Output a newline character ('\n') after printing the intersection.

For example,

insert 2 -5 -5 0

insert 3 -5 -5 -5 2 10 0

insert 2 10 3 -5 0

range_inter -8 16

It should output

-5 2 


range_out: outputs all integer sequences from an integer (first key) to an integer (second key). Output a space character (' ') after printing an integer. Output a newline character ('\n') after printing all elements of a key. Do not print anything if first key equals to second key.

For example,

insert 2 -5 -5 0

insert 3 9 -1 3 -6 0

insert 7 6 1 2 0

range_out -7 12

It should output

3 9 -1 3 -6 

Output

Complete insert, range_diff, range_inter and range_out.

Sample Input  Download

Sample Output  Download

Tags




Discuss