QOJ.ac

QOJ

Time Limit: 1 s Memory Limit: 128 MB Total points: 100

#14644. Rozbicie dzielnicowe

统计

Baitek Bajtocki is a talented young programmer. His parents know about his exceptional skills and often ask him for help with computer-related problems.

This time, Mr. and Mrs. Bajtocki decided to open an account at the Bajtocki Bit Bank (BBB) with online access. To do so, both of them must set up passwords for the account. Baitek’s mother heard at the bank that the safest passwords are those generated by a computer. Not knowing how to do that, both parents asked Baitek for help.

BBB’s website requires each password to consist of at least five characters. Allowed characters are lowercase and uppercase letters, digits, and some punctuation marks—more precisely, all characters with ASCII codes between 48 and 122. To make logging in not too troublesome for his parents, Baitek decided to generate passwords of exactly five characters for both of them.

Baitek easily started a pseudorandom number generator and produced some number of possible passwords. Now he is considering which password to assign to his mother and which to his father. He checked that, for security reasons, the bank service requires the passwords of different account owners to be different. Baitek decided to impress his parents even more and offer them a pair of really different passwords, i.e. passwords that differ at every position.

To make the passwords easier to remember, Baitek would like his mother’s password to resemble the name of one of the Bajtockis’ cats, and his father’s password to resemble the name of their dog. Baitek will make the final choice himself, but for that he would like a list of all pairs of really different passwords from his list. Write a program that generates such a list.

Input

The first line of input contains a single integer $n$ ($2 \le n \le 50{,}000$), the number of passwords generated by Baitek. Each of the next $n$ lines contains five characters with ASCII codes between 48 and 122. You should not assume that the given passwords are random in any way.

Output

The first line of output should contain a single non-negative integer $m$, the number of unordered pairs of really different passwords. Each of the next $m$ lines should contain two integers: the indices of two really different passwords. Passwords are numbered from 1 to $n$ in the order they appear in the input.

If there are more than 100,000 pairs of really different passwords among the input passwords, output any 100,000 such pairs (and then output $m$ as 100,000).

Example

For the input:

3
aB;Va
xBx@a
zc:ng

a correct output is:

2
1 3
2 3

Discussions

About Discussions

The discussion section is only for posting: General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.