codeforces-scrape

Codeforces scraped problems and editorials
git clone git://git.laack.co/codeforces-scrape.git
Log | Files | Refs | README

583A.md (2957B)


      1 Source: https://codeforces.com/problemset/problem/583/A
      2 
      3 A. Asphalting Roads
      4 
      5 time limit per test
      6 
      7 1 second
      8 
      9 memory limit per test
     10 
     11 256 megabytes
     12 
     13 input
     14 
     15 standard input
     16 
     17 output
     18 
     19 standard output
     20 
     21 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.
     22 
     23 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.
     24 
     25 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.
     26 
     27 According to the schedule of road works tell in which days at least one road will be asphalted.
     28 
     29 Input
     30 
     31 The first line contains integer *n* (1 ≤ *n* ≤ 50) — the number of vertical and horizontal roads in the city.
     32 
     33 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.
     34 
     35 Output
     36 
     37 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.
     38 
     39 Examples
     40 
     41 Input
     42 
     43 ```
     44 2  
     45 1 1  
     46 1 2  
     47 2 1  
     48 2 2
     49 ```
     50 
     51 Output
     52 
     53 ```
     54 1 4
     55 ```
     56 
     57 Input
     58 
     59 ```
     60 1  
     61 1 1
     62 ```
     63 
     64 Output
     65 
     66 ```
     67 1
     68 ```
     69 
     70 Note
     71 
     72 In the sample the brigade acts like that:
     73 
     74 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;
     75 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;
     76 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;
     77 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.