Description

City X consists of n vertical and n horizontal infinite roads, forming n × n intersections. Roads (both vertical and horizontal) are numbered from 1 to n, 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 n2 days. On the i-th day of the team arrives at the i-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.

Input

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

Next n2 lines contain the order of intersections in the schedule. The i-th of them contains two numbers hi, vi (1 ≤ hi, vi ≤ n), separated by a space, and meaning that the intersection that goes i-th in the timetable is at the intersection of the hi-th horizontal and vi-th vertical roads. It is guaranteed that all the intersections in the timetable are distinct.

Output

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 1.

Sample Input

Input
2
1 1
1 2
2 1
2 2
Output
1 4 
Input
1
1 1
Output
1 

Hint

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.

题目意思:有n条横向的路和n条纵向的路,交叉得到n*n个路口,要修理路到某个路口,只有当形成这个路口的两条路都没有被修过的时候,这两条路才会被修,问那一天修过路。

解题思路:。。。。。。要什么思路分明是水题,可以我看不懂英语啊,英语是不可能看懂的,这辈子都不可能了(还是好好学吧,捂脸)

上代码:

 #include<stdio.h>
#include<string.h>
int main()
{
int n,x,y,k,i;
int a[],s1[],s2[];
scanf("%d",&n);
k=;
memset(s1,,sizeof(s1));
memset(s2,,sizeof(s2));
for(i=;i<=n*n;i++)
{
scanf("%d%d",&x,&y);
if(s1[x]==&&s2[y]==)
{
s1[x]=;
s2[y]=;
a[k++]=i;
}
}
for(i=;i<k;i++)
{
printf("%d ",a[i]);
}
printf("\n");
return ;
}

最新文章

  1. DOM节点操作
  2. sql导出查询数据
  3. 判断线段和直线相交 POJ 3304
  4. 织梦dedecms后台添加图片style全部都变成st&lt;x&gt;yle的解决办法
  5. React.js终探(五)
  6. linux学习心态建设
  7. commonJS的核心思想
  8. Winform界面中实现通用工具栏按钮的事件处理
  9. SpaceNet数据集
  10. 芝麻HTTP:Ansible扩展
  11. Python内置函数(21)——tuple
  12. IP的种类与获取方式
  13. Linux常用软件启动、停止、重启命令
  14. CentOS7下安装Gitlab社区版【安装步骤、IP改域名、修改端口】
  15. 原来 php 中的 json_encode() 只支持utf-8.不支持gbk啊
  16. python3 通过qq邮箱定时发送邮件
  17. Android 中 LayoutParams 的用法
  18. js如何将一个json数组对应放置到另一数组中去
  19. WebGl 缩放(矩阵变换)
  20. SQL Server -&gt;&gt; SQL Server 2016新特性之 --- Query Store

热门文章

  1. #leetcode刷题之路21-合并两个有序链表
  2. ABAP术语-XML
  3. activeMQ的request-response请求响应模式
  4. querySelectorAll 和 getElementBy 方法的区别
  5. MongoDB DBA 实践4-----创建复制集
  6. Redis(四):解析配置文件redis.conf
  7. 高性能MySQL--MySQL数据类型介绍和最优数据类型选择
  8. 树莓派 ubuntu16.04 安装SSH 配置SSH 开机自启SSH
  9. postgres 输出数据集的自定义函数
  10. 使用mac学习java的一些基本操作