CF583A.Asphalting Roads
入门
通过率:0%
时间限制:1.00s
内存限制:256MB
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
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 _n_2 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.
城市 X 由 n 条纵向和 n 条横向的无限长道路组成,形成 n×n 个交叉路口。纵向与横向道路均编号为 1 至 n,各交叉路口以其所处纵横道路的编号表示。
沙土路面早已被认为过时,因此决定对其铺设沥青。为此,聘请了一支施工队,并制定了工作计划,规定了各交叉路口的铺设顺序。
道路施工计划持续 n2 天。在第 i 天,施工队抵达列表中第 i 个交叉路口;若构成该交叉路口的两条道路(一条纵向、一条横向)均尚未铺设沥青,则同时铺设这两条道路;否则,施工队直接离开该交叉路口,不对任何道路进行操作。
根据道路施工计划,请指出哪些天至少会铺设一条道路。
输入格式
The first line contains integer n (1 ≤ n ≤ 50) — the number of vertical and horizontal roads in the city.
Next _n_2 lines contain the order of intersections in the schedule. The i-th of them contains two numbers h__i, v__i (1 ≤ h__i, v__i ≤ n), separated by a space, and meaning that the intersection that goes i-th in the timetable is at the intersection of the h__i-th horizontal and v__i-th vertical roads. It is guaranteed that all the intersections in the timetable are distinct.
第一行包含一个整数 n(1≤n≤50)—— 表示城市中水平道路与垂直道路的数量。
接下来的 n2 行描述了时刻表中交叉路口的顺序。其中第 i 行包含两个数字 hi、vi(1≤hi,vi≤n),以空格分隔,表示时刻表中第 i 个交叉路口位于第 hi 条水平道路与第 vi 条垂直道路的交点处。保证时刻表中所有交叉路口互不相同。
输出格式
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.
在单行中按升序输出道路施工进行的天数。天数从 1 开始编号。
输入输出样例
输入#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:
- 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;
- 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;
- 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;
- 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.
在样例中,施工队的工作方式如下:
- 第一天,施工队到达第 1 条水平道路与第 1 条垂直道路的交叉口。由于这两条道路均未铺设沥青,工人们铺设了第 1 条垂直道路和第 1 条水平道路;
- 第二天,施工队到达第 1 条水平道路与第 2 条垂直道路的交叉口。第 2 条垂直道路尚未铺设沥青,但第 1 条水平道路已在第一天铺设完毕,因此工人们离开,不进行任何铺设;
- 第三天,施工队到达第 2 条水平道路与第 1 条垂直道路的交叉口。第 2 条水平道路尚未铺设沥青,但第 1 条垂直道路已在第一天铺设完毕,因此工人们离开,不进行任何铺设;
- 第四天,施工队到达第 2 条水平道路与第 2 条垂直道路的交叉口。由于这两条道路均未铺设沥青,工人们铺设了第 2 条垂直道路和第 2 条水平道路。
输入解题思路,AI测评打分。不知道怎么写?