oj mrJudge
Toggle navigation
  • Login
    • Forget Password
      Login
User Image

Hello, Stranger

Guest
  • Analysis Mode
  • Problems
    • All Problems
    • Latest Problems
  • Join Us Now
  • Registration
  • Contact Us
  • Infomation
  • About
    • Terms of Use
    • Technical Specifications
    • Credits

rankandfile Batch , stdin/stdout

Registered Users Only

Please login to utilize this feature.

Do note that this website only supports submissions in C++.

rankandfile.html

Problem

When Sergeant Argus's army assembles for drilling, they stand in the shape of an N by N square grid, with exactly one soldier in each cell. Each soldier has a certain height.

Argus believes that it is important to keep an eye on all of his soldiers at all times. Since he likes to look at the grid from the upper left, he requires that:

  • Within every row of the grid, the soldiers' heights must be in strictly increasing order, from left to right.
  • Within every column of the grid, the soldiers' heights must be in strictly increasing order, from top to bottom.
  • Although no two soldiers in the same row or column may have the same height, it is possible for multiple soldiers in the grid to have the same height.

Since soldiers sometimes train separately with their row or their column, Argus has asked you to make a report consisting of 2*N lists of the soldiers' heights: one representing each row (in left-to-right order) and column (in top-to-bottom order). As you surveyed the soldiers, you only had small pieces of paper to write on, so you wrote each list on a separate piece of paper. However, on your way back to your office, you were startled by a loud bugle blast and you dropped all of the pieces of paper, and the wind blew one away before you could recover it! The other pieces of paper are now in no particular order, and you can't even remember which lists represent rows and which represent columns, since you didn't write that down.

You know that Argus will make you do hundreds of push-ups if you give him an incomplete report. Can you figure out what the missing list is?

Input

The first line will contain an integer N, followed by 2*N-1 lines of N integers each, representing the lists you have, as described in the statement. It is guaranteed that these lists represent all but one of the rows and columns from a valid grid, as described in the statement.

Output

Output one line containing a list of N integers in strictly increasing order, representing the missing list.

Limits

1 ≤ all heights ≤ 2500

The integers on each line will be in strictly increasing order. It is guaranteed that a unique valid answer exists.

Subtask 1 (47%): 2 ≤ N ≤ 10

Subtask 2 (53%): 2 ≤ N ≤ 50

Sample Testcase

Input

3
1 2 3
2 3 5
3 5 6
2 3 4
1 2 3

Output

3 4 6

Explanation

In the sample case, the arrangement must be either this:

1 2 3
2 3 4
3 5 6

or this:

1 2 3
2 3 5
3 4 6

In either case, the missing list is 3 4 6.

Tags

Google Code Jam 2016, Ad Hoc

Subtasks and Limits

Subtask Score #TC Time Memory Scoring
147501s256MBMinimum
253501s256MBMinimum
3011s256MBMinimum

Judge Compile Command

g++-8 ans.cpp -o rankandfile -Wall -Wshadow -static -O2 -lm -m64 -s -w -std=gnu++17 -fmax-errors=512

Accepted Submissions

subIDUserTimeMax Time

Past Submissions

subIDUserTimeScore
mrJudge 09.05.20
Copyright © 2020 mrJudge. All rights reserved.