codeforces-scrape

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

5B.md (1742B)


      1 Source: https://codeforces.com/problemset/problem/5/B
      2 
      3 B. Center Alignment
      4 
      5 time limit per test
      6 
      7 1 second
      8 
      9 memory limit per test
     10 
     11 64 megabytes
     12 
     13 input
     14 
     15 stdin
     16 
     17 output
     18 
     19 stdout
     20 
     21 Almost every text editor has a built-in function of center text alignment. The developers of the popular in Berland text editor «Textpad» decided to introduce this functionality into the fourth release of the product.
     22 
     23 You are to implement the alignment in the shortest possible time. Good luck!
     24 
     25 Input
     26 
     27 The input file consists of one or more lines, each of the lines contains Latin letters, digits and/or spaces. The lines cannot start or end with a space. It is guaranteed that at least one of the lines has positive length. The length of each line and the total amount of the lines do not exceed 1000.
     28 
     29 Output
     30 
     31 Format the given text, aligning it center. Frame the whole text with characters «*» of the minimum size. If a line cannot be aligned perfectly (for example, the line has even length, while the width of the block is uneven), you should place such lines rounding down the distance to the left or to the right edge and bringing them closer left or right alternatively (you should start with bringing left). Study the sample tests carefully to understand the output format better.
     32 
     33 Examples
     34 
     35 Input
     36 
     37 ```
     38 This  is  
     39   
     40 Codeforces  
     41 Beta  
     42 Round  
     43 5
     44 ```
     45 
     46 Output
     47 
     48 ```
     49 ************  
     50 * This  is *  
     51 *          *  
     52 *Codeforces*  
     53 *   Beta   *  
     54 *  Round   *  
     55 *     5    *  
     56 ************
     57 ```
     58 
     59 Input
     60 
     61 ```
     62 welcome to the  
     63 Codeforces  
     64 Beta  
     65 Round 5  
     66   
     67 and  
     68 good luck
     69 ```
     70 
     71 Output
     72 
     73 ```
     74 ****************  
     75 *welcome to the*  
     76 *  Codeforces  *  
     77 *     Beta     *  
     78 *   Round 5    *  
     79 *              *  
     80 *      and     *  
     81 *  good luck   *  
     82 ****************
     83 ```