atcoder#ABC234H. [ABC234Ex] Enumerate Pairs
[ABC234Ex] Enumerate Pairs
Score : points
Problem Statement
Given are pairs of integers , numbered to , and an integer . List all pairs of integers that satisfy the conditions below, in the format specified in Output.
Here, it is guaranteed that there are at most such pairs of integers.
Constraints
- All values in input are integers.
- There are at most pairs of integers that should be listed.
Input
Input is given from Standard Input in the following format:
Output
Print the answer in the following format.
The first line should contain an integer , representing the number of pairs of integers to be listed.
The subsequent lines should contain the pairs of integers to be listed in lexicographical order, each in its own line, separated by a space.
Here, a pair of integers comes before a pair of integers if and only if one of the following conditions is satisfied.
- $a.
- and $b.
6 5
2 0
2 2
3 4
0 0
5 5
8 3
9
1 2
1 3
1 4
2 3
2 4
2 5
3 4
3 5
5 6
There are pairs of integers that satisfy the conditions, which should be printed in the specified format. $(1,2),(1,3),(1,4),(2,3),(2,4),(2,5),(3,4),(3,5),(5,6)$
2 1414213562
0 0
1000000000 1000000000
0
There may be zero pairs of integers that satisfy the conditions.
10 150
300 300
300 400
300 500
400 300
400 400
400 400
400 500
500 300
500 400
500 500
29
1 2
1 4
1 5
1 6
2 3
2 4
2 5
2 6
2 7
3 5
3 6
3 7
4 5
4 6
4 8
4 9
5 6
5 7
5 8
5 9
5 10
6 7
6 8
6 9
6 10
7 9
7 10
8 9
9 10
There may be pairs of integers () such that and .