A. Asphalting Roads
time limit per test

1 second

memory limit per test

256 megabytes

input

standard input

output

standard output

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 test(s)
input
2
1 1
1 2
2 1
2 2

output
1 4

input
1
1 1

output
1

Note

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
题目大意:
给定一个数m,表示有m条竖立的道路和m条横的要修的道路,然后给定
m*m条道路,表示这两条路需要修,如果有两条路都需要修的话就去修,否则
不用修缮。也就是说,只修不在同一行和同一列的
解题思路:
用两个数组分别记下x和y是否被修,然后只需要找出都没有用过的x和y,输出是第几条就行了
直接上代码:
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <queue>
#include <algorithm>
#include <set>
using namespace std;#define MM(a) memset(a,0,sizeof(a))typedef long long LL;
typedef unsigned long long ULL;
const int maxn = 50+5;
const int mod = 1000000007;
const double eps = 1e-7;bool a[maxn], b[maxn];
int main()
{int m;cin>>m;MM(a);MM(b);for(int i=1; i<=m*m; i++){int x, y;cin>>x>>y;if(!a[x] && !b[y]){cout<<i<<" ";a[x] = 1;b[y] = 1;}}return 0;
}

Codeforces Round #323 (Div. 2) A. Asphalting Roads相关推荐

  1. Codeforces Round #323 (Div. 2)

    被进爷坑了,第二天的比赛改到了12点 水 A - Asphalting Roads /************************************************ * Author ...

  2. Codeforces Round #323 (Div. 2) C. GCD Table

    C. GCD Table 题目链接: http://codeforces.com/contest/583/problem/C 题意是给你n个数,可以构成n*n的GCD矩阵,矩阵里的元素顺序可以是任意的 ...

  3. Codeforces Round #323 (Div. 1) B. Once Again... 暴力

    B. Once Again... Time Limit: 1 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/582/probl ...

  4. 重复T次的LIS的dp Codeforces Round #323 (Div. 2) D

    http://codeforces.com/contest/583/problem/D 原题:You are given an array of positive integers a1, a2, . ...

  5. Codeforces Round #323 (Div. 2) C.GCD Table

    C. GCD Table The GCD table G of size n × n for an array of positive integers a of length n is define ...

  6. Codeforces Round #323 (Div. 2): C. GCD Table(思维题)

    题意: 给你一个长度为n的序列a[1]~a[n], 之后用这个序列生成一个n*n的矩阵,其中矩阵第i行第i列的值为a[i],第i行第j列(j!=i)的值为Gcd(a[i], a[j]),现在给你一个矩 ...

  7. Codeforces Round #556 (Div. 1Div. 2)

    Codeforces Round #556 (Div. 1&&Div. 2) 题号 题目 知识点 A Stock Arbitraging 贪心 B Tiling Challenge 贪 ...

  8. Codeforces Round #556 (Div. 1)

    Codeforces Round #556 (Div. 1) A. Prefix Sum Primes 给你一堆1,2,你可以任意排序,要求你输出的数列的前缀和中质数个数最大. 发现只有\(2\)是偶 ...

  9. Codeforces Round #597 (Div. 2) - BenFromHRBUST

    Codeforces Round #597 (Div. 2) -----比赛传送门----- A - Good ol' Numbers Coloring Problem Description Con ...

最新文章

  1. PWM通过RC低通滤波器模拟DAC
  2. 自制精排 ePub 集、不定期更新(UPDATA-2015-8-2)
  3. apue对java_[apue] 一个快速确定新系统上各类限制值的工具
  4. mysql中主从复制包括什么意思_Mysql主从复制作用和工作原理
  5. 取消Win7关机时的补丁更新
  6. C#中扩展StringBuilder支持链式方法
  7. python json操作_Python读取JSON数据操作实例解析
  8. 环境变量查看修改工具 RapidEE(Rapid Environment Editor)
  9. Web开发者必备的十大网站资源(转贴)
  10. 动态规划——Palindrome Partitioning II
  11. 代码检测vc2013环境是否已经安装了
  12. pdf24是什么软件 | pdf24 tools(PDF24工具箱)官方中文版V10.7.1 | pdf24tools下载
  13. COS对象存储服务的使用
  14. python 用泽勒算法计算该天是星期几
  15. 安装uTool之后鼠标中键异常被uTool接管
  16. 降维 php,线性降维方法 - 百度开发者中心的个人空间 - OSCHINA - 中文开源技术交流社区...
  17. 数据库_之常用API的使用
  18. 马云的妻子曝光,背景十分惊人!没有她就没有今天的阿里巴巴.....
  19. Cesium 拾取 API 完全总结
  20. 计算机英语词汇音频,[听单词] 计算机专业英语词汇音频84,计算机英语单词MP3

热门文章

  1. redis设置主从复制-slave Replication--解决报错:(error) READONLY You can't write against a read only slave.
  2. windows开启ssh当跳板机
  3. 华为服务器修改SN,服务器渠道货SN配置
  4. linux mysql 5.0.45_RedHat糸列Mysql-5.0.45的安装
  5. 计算机信息技术在教学中的发展,浅析计算机在信息技术教学中的应用
  6. 工作流引擎 SpringBoot+flowable完美结合,快速实现工作流,so easy
  7. Docker(八):Docker Compose
  8. 联想g400从u盘启动计算机,联想g400u盘装系统的方法
  9. java日历教程_JAVA Calendar方法使用基础教程详解
  10. Windows10为什么自带Linux,一直没有发现原来 Win10 内置了一个 Linux