2778 - I2P(II) 2023_Kuo_HW3 Scoreboard

Time

2023/04/11 15:30:00 2023/04/25 13:20:00

Clarification

# Problem Asker Description Reply Replier Reply Time For all team

# Problem Pass Rate (passed user / total user)
11422 Shape
12286 Matrix
13172 Powers
13861 KTV ordering system

11422 - Shape   

Description

Warning: You are not allowed to use malloc and free

Following the lecture slide :

Giving a bass-class Shape and 3 derived class : Triangle, Rectangle, Circle

You need to calculate the area and the perimeter of each shape.

note : You need to do some basic check: if the given information cannot form a shape (e.g. height of the rectangle is negative number....etc), then the area and perimeter would be both 0)

Input

There are only 3 shapes in this problem :

  • Triangle, following by its 3 edges. (e.g. Triangle 3 4 5)
  • Rectangle, following by its width and height. (e.g. Rectangle 5 7)
  • Circle, following by its radius and the value of pi. (e.g. Circle 2 3.14)

Output

Ouput the total area and perimeter of all the shapes.

Sample Input  Download

Sample Output  Download

Partial Judge Code

11422.cpp

Partial Judge Header

11422.h

Tags




Discuss




12286 - Matrix   

Description

Create a class Matrix to represent an N * N matrix.

 

Provide public member functions that perform or derive:

     1) Matrix(const Matrix &);  // copy constructor

 

     2) Overload the stream extraction operator (>>) to read in the matrix elements.

 

    3)  Overload the stream insertion operator (<<) to print the content of the matrix row by row.

 

     4)  Default constructor

 

    5)  Overload the operator (=) to assign value to matrix.

         Note that all of the integers in the same line are separated by a space, and there is a new line character at the end of each line.

 

Note:

1.  This problem involves three files.

  • function.h: Class definition of Matrix.
  • function.cpp: Member-function definitions of Matrix.
  • main.cpp: A driver program to test your class implementation.

You will be provided with function.h and main.cpp, and asked to implement 

 

2. For OJ submission:

       Step 1. Include function.h into function.cpp and then implement your function.cpp. (You don’t need to modify function.h and main.cpp)

       Step 2. Submit the code of function.cpp into submission block.

       Step 3. Check the results and debug your program if necessary.

Input

The first line has an integer N (1<=N<=50), which means the size of the matrix. The total number of elements in the matrix is thus N * N.

 

For the next N lines specify the elements of the matrix a. All of the integers in the same line are separated by a space.

Output

Your program should print the corresponding results followed by a new line character.

Sample Input  Download

Sample Output  Download

Partial Judge Code

12286.cpp

Partial Judge Header

12286.h

Tags

matrix



Discuss




13172 - Powers   

Description

This is a partial judge problem.

In this problem, you have to implement some power function in class special_power:

  • special_power(int n)  default constructor
  • int fpow(int x)  return xn % 880301
  • int fpow(int x, int m)  return xn % m
  • int fpow()  return 2n % 880301
  • string fpow(string s)  return sn
  • string fpow(string s, int m)  return sn % m

Note that n is a member in class special_power.

The definition of sn

Repeat the elements of s n times, and connect them

For example:

  • abcd4 = aaaabbbbccccdddd
  • csst3 = cccssssssttt

The definition of sn % m:

Repeat the elements of s n times, and connect them.

If the length of sn is longer than m, ignore the remaining elements.

For example:

  • abcd4 % 10 = aaaabbbbcc
  • csst3 % 4 = cccs

Input

The input has only one line, contains three integer x, n, m and one string s.

For all testcase:

  • 1 <= x, m <= 109
  • 1 <= n <= 106
  • 1 <= |s| <= 1000
  • (1/6) 1 <= xn, 2n < m <= 880301, 1 <= |s| * n <= m
  • (1/6) 1 <= xn, 2n < m <= 880301
  • (1/6) 1 <= |s| * n <= m

Output

The output has five lines.

The 1st line, output the result of xn % 880301

The 2nd line, output the result of xn % m

The 3rd line, output the result of 2n % 880301

The 4th line, output the result of sn

The 5th line, output the result of sn % m

Sample Input  Download

Sample Output  Download

Partial Judge Code

13172.cpp

Partial Judge Header

13172.h


Discuss




13861 - KTV ordering system   

Description

 

After graduating from NTHU CS, since your teamates and you all love singing, you are asked to write a song ordering system for them. 

Beside the basic operations: order, play, show, since someone may suddenly want to sing a certain song, so you have to add an operation called "insert". The rule of "insert" is that when you insert a new song (a totally new one or one has been ordered), it will be added to the end of all the inserted songs. And if you insert it the second or more time, it will become the next song to play (the first of all the inserted songs).

The playlist of the songs can be seen as three parts: songs have been played, songs have been inserted, and songs ordered by ordinary way. Let's denote them as played part, inserted part, ordered part, and the whole list is called playlist.

There are 4 operations in the ordering system:

  • order(int k): add song k to the end of the ordered part, it's guaranteed that k is not in the playlist before.
  • insert(int k): (it's guarantee that k has not been played before)
    • For song k that has been inserted at lease once(insert k): put k at the beginning of the inserted part.
    • If song k isn't in the playlist: add k to the end of the inserted part.
    • If song k is in the ordered part: move k from the ordered part to the end of the inserted part.
  • play(): print the number of the next song, and move it to the played part. If there are no unplayed songs(inserted part and ordered part are both empty), please print "All songs are played.".
  • show(); print the whole playlist, songs that were played in the first line, songs that are still waiting should be printed on in the second line.

 

Take the first sample testcase for example, after each operation, the playlist may be like (played part | inserted part | ordered part):

order 6:  | | 6

play: 6 | |        

order 4: 6 | | 4

insert 3: 6 | 3 | 4

show: 6 | 3 | 4

order 2: 6 | 3 | 4 2

insert 5: 6 | 3 5 | 4 2

insert 1: 6 | 3 5 1 | 4 2

show: 6 | 3 5 1 | 4 2

insert 1: 6 | 1 3 5 | 4 2

show: 6 | 1 3 5 | 4 2

 

This problem is partial judge (Don't forget to include "function.h"!), you need to finish the following functions:

  • void initialize(): you can do whatever you want to initialize the class, it's also ok to do nothing
  • void order(int k): same as the above
  • void play(): same as the above
  • void show(): same as the above
  • void insert(int k): same as the above
  • void destroy(): same as initialize, but this is used to destroy the class

The function print(song *st, song *en) can print songs in [st, en), you can use it to avoid presentation error.

 

Input

The first line contains an integer T -- the testcases.

In the first line of each testcase is an integer N -- the number of operations.

The following N lines will be the operations -- order k, insert k, play, show.

For testcase 1~3: 1 <= N <= 1000.

For testcase 4~6: 1 <= N <= 1e5. It's guarantee that the number of "show" is under 200.

For all testcases: 1 <= T <= 10, 1 <= k <= 1e6.

Output

For operation "play", print the number of the next song to play, if there are no such song, please print "All songs are played.".

For operation "show", print two lines, the first line contains all the number of played songs, while the second line contains the songs have been ordered or inserted but haven't been played yet.

Sample Input  Download

Sample Output  Download

Partial Judge Code

13861.cpp

Partial Judge Header

13861.h

Tags




Discuss