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 some number of commands.
C lines, where each line 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.
```python
def f(N: int, C: int, commands: List[str]):
'''
N: an integer
C: an integer
commands: a list of strings
'''
```
Test Case Generator
Sure, here's a test case generator for the provided competitive programming problem "Programming Contest II":
```python
import random
def generate_update_command(N):
t = random.randint(1, N)
p = random.randint(1, 10**9)
return f"0 {t} {p}"
def generate_report_command(N):
m = random.randint(1, N)
return f"1 {m}"
def tcgen():
N = random.randint(2, 100000)
C = random.randint(1, 100000)
commands = []
for _ in range(C):
if random.choice([True, False]):
commands.append(generate_update_command(N))
else:
commands.append(generate_report_command(N))
# Ensure at least one report command (per problem guarantee)
if not any(cmd.startswith('1') for cmd in commands):
commands[random.randint(0, C-1)] = generate_report_command(N)
return N, C, commands
def print_test_case():
N, C, commands = tcgen()
print(N, C)
for command in commands:
print(command)
# Generate and print a test case
print_test_case()
```
Explanation:
1. **Random Values**:
- `N`: Number of teams, randomly chosen between 2 and 100000.
- `C`: Number of commands, randomly chosen between 1 and 100000.
2. **Command Generation**:
- `generate_update_command(N)`: Generates an update command `0 t p` where `t` is a random team number and `p` is a random score to add.
- `generate_report_command(N)`: Generates a report command `1 m` where `m` is a random rank to report.
3. **Ensure At Least One Report Command**:
- The generator ensures that there is at least one report command in the list of commands, as guaranteed by the problem statement.
4. **Output**:
- The `print_test_case` function is used to print the generated test case in the required format.
You can run `print_test_case()` to generate and display a test case. Each run will provide a different set of inputs based on random values.
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