QOJ.ac

QOJ

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

#321. Sticks

Statistics

Little Johnny was given a birthday present by his grandparents. This present is a box of sticks of various lengths and colours. Johnny wonders if there are three sticks in the set he has been given that would form a triangle with different-coloured sides. Let us note that Johnny is interested in non-degenerate triangles only, i.e., those with positive area.

Input Format

In the first line of the standard input an integer $k$ ($3 ≤ k ≤ 50$) is given, which is the number of different colours of sticks. The colours themselves are numbered from $1$ to $k$.

The following $k$ lines contain descriptions of the sticks of particular colours. The line no. i+1 holds integers that describe the sticks of colour i, separated by single spaces. The first of these numbers, $n_i$ ($1 ≤ n_i ≤ 1\,000\,000$), denotes the number of sticks of colour $i$. It is followed, in the same line, by ni integers denoting the lengths of the sticks of colour $i$. All lengths are positive and do not exceed $1\,000\,000\,000$. Furthermore, the total number of all sticks does not exceed $1\,000\,000$.

In tests worth at least $30\%$ of the points the following holds in addition: the total number of the sticks does not exceed 250.

Output Format

Your program should print (on the first and only line of the standard output) either:

  • six integers, separated by single spaces, that describe the construction of a triangle with different-coloured sides as follows: the colour and the length of the first stick, the colour and the length of the second stick, and the colour and the length of the third stick,
  • or the word NIE (Polish for no) if no such triple of sticks exists.

If there are multiple triples of different-coloured sticks that give rise to a triangle, your program may pick one such triple arbitrarily.

Sample Data

Sample Input

4
1 42
2 6 9
3 8 4 8
1 12

Sample Output

3 8 4 12 2 9
About Issues

We understand that our problem archive is not perfect. If you find any issues with the problem, including the statement, scoring configuration, time/memory limits, test cases, etc.

You may use this form to submit an issue regarding the problem. A problem moderator will review your issue and proceed it properly.

STOP! Before you submit an issue, please READ the following guidelines:

  1. This is not a place to publish a discussion, editorial, or requests to debug your code. Your issue will only be visible by you and problem moderators. Other users will not be able to view or reply your issues.
  2. Do not submit duplicated issues. If you have already submitted one, please wait for an moderator to review it. Submitting multiple issues will not speed up the review process and might cause your account to be banned.
  3. Issues must be filed in English or Chinese only.
  4. Be sure your issue is related to this problem. If you need to submit an issue regarding another problem, contest, category, etc., you should submit it to the corresponding page.

Active Issues 0

No issues in this category.

Closed/Resolved Issues 0

No issues in this category.