Orig Description
Score : 1000 points
Problem StatementRed bold fonts show the difference from C1.
There is an infinitely large triangular grid, as shown below.
Each point with integer coordinates contains a lamp.
Initially, only the lamp at (X, Y) was on, and all other lamps were off.
Then, Snuke performed the following operation zero or more times:
Choose two integers x and y.
Toggle (on to off, off to on) the following three lamps: (x, y), (x, y+1), (x+1, y).
After the operations, N lamps (x_1, y_1), \cdots, (x_N, y_N) are on, and all other lamps are off.
Find X and Y.
Constraints
1 \leq N \leq 10^4
-10^{17} \leq x_i, y_i \leq 10^{17}
(x_i, y_i) are pairwise distinct.
The input is consistent with the statement, and you can uniquely determine X and Y.
InputInput is given from Standard Input in the following format:
N
x_1 y_1
:
x_N y_N
OutputPrint X and Y, separated by a space.
Sample Input 14
-2 1
-2 2
0 1
1 0
Sample Output 1-1 0
The following picture shows one possible sequence of operations:
Extracted Specification
An integer N (1 ≤ N ≤ 10^4), representing some quantity or size.
A list of N tuples, where each tuple contains two integers (x, y) such that -10^17 ≤ x, y ≤ 10^17. The tuples are pairwise distinct.
### Example Input:
```
4
-2 1
-2 2
0 1
1 0
```
### Function Signature:
Write a function f(inputs) that takes in the input.
def f(inputs: List[Tuple[int, int]]):
'''
inputs: a list of tuples, where each tuple contains two integers
'''
Test Case Generator
Certainly! Let's create a test case generator for the given problem statement. The task involves generating a list of \(N\) distinct coordinates within the specified range.
Here's the test case generator function in Python:
```python
import random
def generate_coordinates(N):
coordinates = set()
while len(coordinates) < N:
x = random.randint(-10**17, 10**17)
y = random.randint(-10**17, 10**17)
coordinates.add((x, y))
return list(coordinates)
def tcgen():
N = random.randint(1, 10**4)
coordinates = generate_coordinates(N)
return N, coordinates
# Example usage
N, coordinates = tcgen()
print(N)
for coord in coordinates:
print(coord[0], coord[1])
```
### Explanation:
1. **generate_coordinates(N)**: This function generates \(N\) distinct coordinates within the range \([-10^{17}, 10^{17}]\).
- We use a set to ensure that the coordinates are unique.
- We loop until we have \(N\) distinct coordinates.
- For each coordinate, random integers are generated for both \(x\) and \(y\) within the specified range.
- The generated coordinates are added to the set.
- Finally, the set is converted to a list and returned.
2. **tcgen()**: This function generates the full test case.
- It first generates a random number \(N\) within the range \([1, 10^4]\).
- Then, it calls the `generate_coordinates` function to get \(N\) unique coordinates.
- It returns \(N\) and the list of coordinates.
3. **Example usage**: The last part demonstrates how to use the `tcgen()` function to generate and print a test case.
This generator ensures that the constraints are met, and you will get a new random test case each time you run it.
Extract Arguments
def extract_arguments(fh):
N = int(fh.readline().strip())
lamps = []
for _ in range(N):
x, y = map(int, fh.readline().strip().split())
lamps.append((x, y))
return N, lamps
# if __name__ == "__main__":
# input_path = sys.argv[1]
# with open(input_path, 'r') as fh:
# N, lamps = extract_arguments(fh)
# f(N, lamps)