Csc3100 Spring2024 Assignment2
Csc3100 Spring2024 Assignment2
Requirements
Code (90%)
You can write your code in Java, Python, C, or C++. The time limit may vary among di↵erent
languages, depending on the performance of the language. Your code must be a complete excutable
program instead of only a function. We guarantee test data strictly compliance with the requirements
in the description, and you do not need to deal with cases where the input data is invalid.
Libraries in this assignment:
• For C/C++, you can only include standard library.
• For Java, you can only import java.util.*
• For Python, you can only import standard library. In other words, you cannot import libraries
such as numpy.
Report (10%)
You also need to write a report in pdf type to explain the following:
• What are the possible solutions for the problem?
• How do you solve this problem?
• Why is your solution better than others?
Please note that the maximum number of pages allowed for your report is 5 pages.
Remember that the report is to illustrate your thinking process. Keep in mind that your report is
supposed to show your ideas and thinking process. We expect clear and precise textual descriptions
in your report, and we do not recommend that you over-format your report.
Input
Two integers in one line: A, and B
Output
One integer: A + B
1
Solutions
Java
import java . util .*;
Python
AB = input (). split ()
A , B = int ( AB [0]) , int ( AB [1])
print ( A + B )
C
# include < stdio .h >
C++
# include < iostream >
C. Submission
After finishing this assignment, you are required to submit your code to the Online Judge System
(OJ), and upload your .zip package of your code files and report to BlackBoard.
2
Note: The program running time may vary on di↵erent machines. Please refer to the result of
the online judge system. OJ will show the time and memory limits for di↵erent languages on the
corresponding problem page.
If you have other questions about the online judge system, please refer to OJ wiki (campus network
only). If this cannot help you, feel free to contact us.
C.2 BlackBoard
You are required to upload your source codes and report to the BlackBoard platform. You need
to name your files according to the following rules and compress them into A1_<Student ID>.zip :
A1_ < Student ID >. zip
| - - A1_P1_ < Student ID >. java / py / c / cpp
| - - A1_P2_ < Student ID >. java / py / c / cpp
| - - A1_Report_ < Student ID >. pdf
For Java users, you don’t need to consider the consistency of class name and file name.
For example, suppose your ID is 123456789, and your problem 1 is written in Python, problem 2 is
written in Java then the following contents should be included in your submitted A1_123456789.zip:
A1_123456789 . zip
| - - A1 _P 1_ 1 23 45 67 8 9 . py
| - - A1 _P 2_ 1 23 45 67 8 9 . java
| - - A 1 _ R e p o r t _ 1 2 3 4 5 6 7 8 9 . pdf
FAQs
Q: I cannot access to Online Judge.
A: First, please ensure that you are using the campus network. If you are not on campus, please use
the university VPN. Second, please delete cookies and refresh browser or use other browser. If you
still cannot access to Online Judge, try to visit it via the IP address 10.26.200.13.
Q: My program passes samples on my computer, but not get AC on OJ.
A: Refer to OJ Wiki Q&A
Authors
If you have questions for the problems below, please contact:
• Problem 1. Xuanzhuo Liu: [email protected]
• Problem 2. Yingli Zhou: [email protected]
• Problem 3. Yohandi: [email protected]
3
CSC3100 Data Structures Spring 2024
Programming Assignment 2
1.2 Input
The first line of input contains an integer n, representing the number of players. The next n lines
follow. The i-th line represents i-th player. If i-th player leaves a note to j-th player, the j-th entry is
1.
1.3 Output
For each test case, output the winner’s label if there is a winner in the game. If there is no winner,
return -1.
4
Sample Input 2 Sample Output 2
4 -1
0 0 1 0
0 0 1 0
0 1 0 0
0 0 1 0
Hint
You may try to find the winner in O(N) time.
2.2 Input
The first line of input contains an integer n, representing the number of houses, and an integer k. The
second line of input contains an array houses with length n.
2.3 Output
An array that lists the tallest house visible.
5
Sample Input 2 Sample Output 2
5
8 3 7
1 3 5 7 9 11 13 15 9
11
13
15
3.3 Input
You are given a sequence of n digits and an integer m.
3.4 Output
The smallest possible number after taking out m digits away from the given sequence.
6
Sample Input 1 Sample Output 1
1234 4 0