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 another quantity or size.
A list of C commands, each being one of the following types:
- "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 given problem statement:
```python
import random
def tcgen():
# Generate N (2 ≤ N ≤ 100000)
N = random.randint(2, 100000)
# Generate C (1 ≤ C ≤ 100000)
C = random.randint(1, 100000)
commands = []
for _ in range(C):
command_type = random.choice([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
# Generate a sample test case
N, C, commands = tcgen()
# Print the test case in the required format
print(N, C)
for command in commands:
print(command)
```
Explanation:
1. **Generate N**: The number of teams is randomly selected between 2 and 100000.
2. **Generate C**: The number of commands is randomly selected between 1 and 100000.
3. **Generate commands**:
- For each command, randomly decide whether it is an update command (`0 t p`) or a report command (`1 m`).
- For update commands, generate a team number `t` between 1 and N and a score `p` between 1 and \(10^9\).
- For report commands, generate a rank `m` between 1 and N.
4. **Return**: The generated test case is returned in the required format.
This test case generator creates various random scenarios adhering to the constraints of the problem statement.
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)