CodeForces 583A

E -E
Crawling in process... Crawling failed
Time Limit: 1000MS     Memory Limit: 262144KB     64bit IO Format: %I64d & %I64u

Description

City X consists of n vertical and n horizontal infinite roads, forming n × n intersections. Roads (both vertical and horizontal) are numbered from1 ton, 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 thei-th day of the team arrives at thei-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. Thei-th of them contains two numbershi, 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 from1.

Sample Input

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

Sample Output

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.
思路:可能是女神眷顾吧,前几道a的有点顺了,这道题开始浪了,wa了两次;
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
int a[3010],h[3010],v[3010];
int main()
{
	int n,i,x,y;
	while(scanf("%d",&n)!=EOF)
	{
		int j=0;
		memset(a,0,sizeof(a));
		memset(h,0,sizeof(h));
		memset(v,0,sizeof(v));
		for(i=1;i<=n*n;i++)
		{
			scanf("%d %d",&x,&y);
			if(!h[x] && !v[y])
			{
				a[j]=i;
				j++;
				h[x]=1;
				v[y]=1;
			}
		}
		for(i=0;i<j;i++)
		{
			if(i>0) printf(" ");
			printf("%d",a[i]);
		}
		printf("\n");
	}
	return 0;
}

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值