codeforces-scrape

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

1068C.md (2706B)


      1 Source: https://codeforces.com/problemset/problem/1068/C
      2 
      3 C. Colored Rooks
      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 Ivan is a novice painter. He has $n$ dyes of different colors. He also knows exactly $m$ pairs of colors which harmonize with each other.
     22 
     23 Ivan also enjoy playing chess. He has $5000$ rooks. He wants to take $k$ rooks, paint each of them in one of $n$ colors and then place this $k$ rooks on a chessboard of size $10^{9} \times 10^{9}$.
     24 
     25 Let's call the set of rooks on the board connected if from any rook we can get to any other rook in this set moving only through cells with rooks from this set. Assume that rooks can jump over other rooks, in other words a rook can go to any cell which shares vertical and to any cell which shares horizontal.
     26 
     27 Ivan wants his arrangement of rooks to have following properties:
     28 
     29 * For any color there is a rook of this color on a board;
     30 * For any color the set of rooks of this color is connected;
     31 * For any two different colors $a$ $b$ union of set of rooks of color $a$ and set of rooks of color $b$ is connected if and only if this two colors harmonize with each other.
     32 
     33 Please help Ivan find such an arrangement.
     34 
     35 Input
     36 
     37 The first line of input contains $2$ integers $n$, $m$ ($1 \le n \le 100$, $0 \le m \le min(1000, \,\, \frac{n(n-1)}{2})$) — number of colors and number of pairs of colors which harmonize with each other.
     38 
     39 In next $m$ lines pairs of colors which harmonize with each other are listed. Colors are numbered from $1$ to $n$. It is guaranteed that no pair occurs twice in this list.
     40 
     41 Output
     42 
     43 Print $n$ blocks, $i$-th of them describes rooks of $i$-th color.
     44 
     45 In the first line of block print one number $a_{i}$ ($1 \le a_{i} \le 5000$) — number of rooks of color $i$. In each of next $a_{i}$ lines print two integers $x$ and $y$ ($1 \le x, \,\, y \le 10^{9}$) — coordinates of the next rook.
     46 
     47 All rooks must be on different cells.
     48 
     49 Total number of rooks must not exceed $5000$.
     50 
     51 It is guaranteed that the solution exists.
     52 
     53 Examples
     54 
     55 Input
     56 
     57 ```
     58 3 2  
     59 1 2  
     60 2 3
     61 ```
     62 
     63 Output
     64 
     65 ```
     66 2  
     67 3 4  
     68 1 4  
     69 4  
     70 1 2  
     71 2 2  
     72 2 4  
     73 5 4  
     74 1  
     75 5 1
     76 ```
     77 
     78 Input
     79 
     80 ```
     81 3 3  
     82 1 2  
     83 2 3  
     84 3 1
     85 ```
     86 
     87 Output
     88 
     89 ```
     90 1  
     91 1 1  
     92 1  
     93 1 2  
     94 1  
     95 1 3
     96 ```
     97 
     98 Input
     99 
    100 ```
    101 3 1  
    102 1 3
    103 ```
    104 
    105 Output
    106 
    107 ```
    108 1  
    109 1 1  
    110 1  
    111 2 2  
    112 1  
    113 3 1
    114 ```
    115 
    116 Note
    117 
    118 Rooks arrangements for all three examples (red is color $1$, green is color $2$ and blue is color $3$).
    119 
    120 ![](https://espresso.codeforces.com/d5e9a3c617c702cf17f054591d95a580aee4dec6.png)
    121 
    122 ![](https://espresso.codeforces.com/44f95babdb0711e1c18646be8f038c4cb07f7995.png)
    123 
    124 ![](https://espresso.codeforces.com/19af8d26102ef8df929a82b65eb924ff667d677d.png)