633 - EECS111000_I2P2014_Mid1 Scoreboard

Time

2014/10/29 08:00:00 2014/10/29 10:05:00

Clarification

# Problem Asker Description Reply Replier Reply Time For all team

# Problem Pass Rate (passed user / total user)
10199 Problem 1
10200 Problem 2
10202 Problem 3

10199 - Problem 1   

Description

The input is a string of letters, for example,

BbBTTtttTUuUuUUuUuUukk

Find the length of the longest consecutive lowercase letters. For the above example, the answer is 3, because the longest consecutive letters are ttt.

Hint:
I. Use while((ch=getchar())!='\n') { … } to read the input data.
II. Use another variable prev to remember the previous letter.
III. Include ctype.h so that you can use islower(ch) to check if ch is lowercase.
IV. The algorithm can be summarized as follows:
while loop: read the current letter and do the loop when the letter is not '\n'

i)       if the letter is different from the previous one

a.  compare the length of the current repeat letter with the longest length we have seen so far; if the length of the current letter is longer, then update the longest length as the new one.

b.  update the prev as ch

c.  reset the length of the current repeat letter as 1 because we start with a new letter

ii)     else

a.  if islower(ch), then increase the length of the current repeat letter by 1

 

Input

The input is a string of English letters, which can be uppercase or lowercase. There are no whitespaces between the letters, and the input is ended with '\n'.

Output

The output is a number indicating the length of the longest consecutive lowercase letters. Be sure to add a newline character '\n' at the end.

Sample Input  Download

Sample Output  Download

Tags




Discuss




10200 - Problem 2   

Description

Consider a vector of length 10 with all components being zero. Given a sequence of operations on the vector, compute the sum of the vector after carrying out all of the operations. The operations are presented in a format as follows:
3 A 10
2 A 30
5 A 70
2 S 50
3 S 6
5 S 68
where 'A' is for addition and 'S' is for subtraction. The first operation "3 A 10" means that 10 is added to the third component. The second operation "2 A 30" means that 30 is added to the second component, and so on. The last operation means that 68 is subtracted from the fifth component. Note that the components of the vector cannot be negative. Therefore, if an operation will cause some component to become negative, that operation is ignored and does not make any change to the vector. For example, the forth operation "2 S 50" in the above sequence will be ignored since at that moment the value of the second component is only 30, which is not enough for subtracting 50
.
The final sum of the vector after the above operations will be 36.

 

Input

The first line is an integer N (1<=N<=1000) denoting the number of operations.

The next N lines contain the N operations in the form of
Component_Index Add_Or_Subtract Component_Value

Component_Index is within the range from 1 to 10. Component_Value is a positive integer.

Output

 The output is a line that presents the sum of the vector after the operations. Be sure to add a newline character '\n' at the end.

Sample Input  Download

Sample Output  Download

Tags




Discuss




10202 - Problem 3   

Description

Given a square matrix of size N-by-N, compute its smallest row sum and smallest column sum. For example, if the matrix is
4 9 2
1 6 5
7 8 3
the smallest row sum is 12 (the sum of the second row), and the smallest column sum is 10 (the sum of the third column).

Input

The first line is an integer N (1<=N<=10) denoting the size of the matrix.
The next N lines contain the N*N elements of the matrix. The elements of the matrix are nonnegative integers.

Output

The results are shown in two lines. The first line is the smallest row sum and the second line is the smallest column sum. Each line is ended with a newline character '\n'.

Sample Input  Download

Sample Output  Download

Tags




Discuss