Orig Description
Programming Contest II
Every year, Hakuto University holds a programming contest. The contest starts with all team scores at 0, and points are added based on the answers. In this contest, teams are ranked in order of their scores. Teams are assigned numbers from 1 to N, the total number of teams. In case of a tie, the team with the smaller number is ranked higher.
To make the contest more exciting, Hakuto University is developing a ranking system for spectators. As a member of the development team, you are responsible for creating a program that updates the scores and reports the team number and score for the specified rank according to the given commands.
Input
The input is given in the following format:
N C
command1
command2
:
commandC
The first line contains the number of teams N (2 ≤ N ≤ 100000) and the number of commands C (1 ≤ C ≤ 100000). The following C lines give the commands, one per line. Each command is given in the following format:
0 t p
or
1 m
The first digit indicates whether the command is an update command (0) or a report command (1). In an update command, the team specified by the number t (1 ≤ t ≤ N) is given an integer score p (1 ≤ p ≤ 109) to add to its current score. In a report command, the team number and score for the specified rank m (1 ≤ m ≤ N) are reported. It is guaranteed that at least one report command will appear.
Output
For each report command, output the team number and score for the specified rank on a single line separated by a space.
Sample Input 1
3 11
0 2 5
0 1 5
0 3 4
1 1
1 2
1 3
0 3 2
1 1
0 2 1
1 2
1 3
Sample Output 1
1 5
2 5
3 4
3 6
3 6
1 5
Sample Input 2
5 2
1 1
1 2
Sample Output 2
1 0
2 0
Extracted Specification
An integer N (2 ≤ N ≤ 100000), representing some quantity or size.
An integer C (1 ≤ C ≤ 100000), representing the number of commands.
A list of C commands, each command is either:
- '0 t p' where t is an integer (1 ≤ t ≤ N), and p is an integer (1 ≤ p ≤ 10^9).
- '1 m' where m is an integer (1 ≤ m ≤ N).
### Example Input:
```
3 11
0 2 5
0 1 5
0 3 4
1 1
1 2
1 3
0 3 2
1 1
0 2 1
1 2
1 3
```
### Function Signature:
Write a function f(N, C, commands) that takes in the input.
def f(N: int, C: int, commands: List[str]):
'''
N: an integer
C: an integer
commands: a list of strings
'''
Test Case Generator
Sure, I can help you write a test case generator for the given problem statement. Below is the Python code to generate test cases for the "Programming Contest II" problem:
```python
import random
def tcgen():
# Generate the number of teams N and the number of commands C
N = random.randint(2, 100000)
C = random.randint(1, 100000)
commands = []
for _ in range(C):
# Randomly decide if the command will be an update or a report
command_type = random.randint(0, 1)
if command_type == 0:
# Update command: 0 t p
t = random.randint(1, N)
p = random.randint(1, 10**9)
commands.append(f"0 {t} {p}")
else:
# Report command: 1 m
m = random.randint(1, N)
commands.append(f"1 {m}")
return N, C, commands
# Example usage:
N, C, commands = tcgen()
print(N, C)
for command in commands:
print(command)
```
### Explanation:
1. **Generate `N` and `C`:** We randomly decide the number of teams `N` (between 2 and 100000) and the number of commands `C` (between 1 and 100000).
2. **Generate Commands:**
- For each command:
- Randomly decide whether it is an update command (`0 t p`) or a report command (`1 m`).
- If it is an update command, generate a team number `t` (between 1 and `N`) and a score `p` (between 1 and 10^9).
- If it is a report command, generate a rank `m` (between 1 and `N`).
3. **Return the Test Case:** The generated test case consists of `N`, `C`, and the list of commands.
You can adjust the ranges or the probabilities of different types of commands if required. The example usage at the end demonstrates how to generate and print a test case.
Extract Arguments
def extract_arguments(fh):
N, C = map(int, fh.readline().strip().split())
commands = [fh.readline().strip() for _ in range(C)]
return N, C, commands
# if __name__ == "__main__":
# input_path = sys.argv[1]
# with open(input_path, 'r') as fh:
# N, C, commands = extract_arguments(fh)
# f(N, C, commands)