CF583A.Asphalting Roads

普及/提高-

通过率:0%

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

City X consists of nn vertical and nn horizontal infinite roads, forming n×nn×n intersections. Roads (both vertical and horizontal) are numbered from 11 to nn , and the intersections are indicated by the numbers of the roads that form them.

Sand roads have long been recognized out of date, so the decision was made to asphalt them. To do this, a team of workers was hired and a schedule of work was made, according to which the intersections should be asphalted.

Road repairs are planned for n2n^{2} days. On the ii -th day of the team arrives at the ii -th intersection in the list and if none of the two roads that form the intersection were already asphalted they asphalt both roads. Otherwise, the team leaves the intersection, without doing anything with the roads.

According to the schedule of road works tell in which days at least one road will be asphalted.

输入格式

The first line contains integer nn ( 1<=n<=501<=n<=50 ) — the number of vertical and horizontal roads in the city.

Next n2n^{2} lines contain the order of intersections in the schedule. The ii -th of them contains two numbers hi,vih_{i},v_{i} ( 1<=hi,vi<=n1<=h_{i},v_{i}<=n ), separated by a space, and meaning that the intersection that goes ii -th in the timetable is at the intersection of the hih_{i} -th horizontal and viv_{i} -th vertical roads. It is guaranteed that all the intersections in the timetable are distinct.

输出格式

In the single line print the numbers of the days when road works will be in progress in ascending order. The days are numbered starting from 11 .

输入输出样例

  • 输入#1

    2
    1 1
    1 2
    2 1
    2 2
    

    输出#1

    1 4 
    
  • 输入#2

    1
    1 1
    

    输出#2

    1 
    

说明/提示

In the sample the brigade acts like that:

  1. On the first day the brigade comes to the intersection of the 1-st horizontal and the 1-st vertical road. As none of them has been asphalted, the workers asphalt the 1-st vertical and the 1-st horizontal road;
  2. On the second day the brigade of the workers comes to the intersection of the 1-st horizontal and the 2-nd vertical road. The 2-nd vertical road hasn't been asphalted, but as the 1-st horizontal road has been asphalted on the first day, the workers leave and do not asphalt anything;
  3. On the third day the brigade of the workers come to the intersection of the 2-nd horizontal and the 1-st vertical road. The 2-nd horizontal road hasn't been asphalted but as the 1-st vertical road has been asphalted on the first day, the workers leave and do not asphalt anything;
  4. On the fourth day the brigade come to the intersection formed by the intersection of the 2-nd horizontal and 2-nd vertical road. As none of them has been asphalted, the workers asphalt the 2-nd vertical and the 2-nd horizontal road.
首页