codeforces-scrape

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

147A.md (1463B)


      1 Source: https://codeforces.com/problemset/problem/147/A
      2 
      3 A. Punctuation
      4 
      5 time limit per test
      6 
      7 2 seconds
      8 
      9 memory limit per test
     10 
     11 256 megabytes
     12 
     13 input
     14 
     15 stdin
     16 
     17 output
     18 
     19 stdout
     20 
     21 You are given a text that consists of lowercase Latin letters, spaces and punctuation marks (dot, comma, exclamation mark and question mark). A word is defined as a sequence of consecutive Latin letters.
     22 
     23 Your task is to add spaces to the text by the following rules:
     24 
     25 * if there is no punctuation mark between two words, then they should be separated by exactly one space
     26 * there should be no spaces before each punctuation mark
     27 * there should be exactly one space after each punctuation mark
     28 
     29 It is guaranteed that there is at least one word between any two punctuation marks. The text begins and ends with a Latin letter.
     30 
     31 Input
     32 
     33 The input data contains of a single non-empty line — the text whose length is no more than 10000 characters.
     34 
     35 Output
     36 
     37 Print the text, edited according to the rules. In this problem you should follow the output format very strictly. For example, extra space at the end of the output line is considered as wrong answer. Note that a newline character at the end of the line doesn't matter.
     38 
     39 Examples
     40 
     41 Input
     42 
     43 ```
     44 galileo galilei was an   italian physicist  ,mathematician,astronomer
     45 ```
     46 
     47 Output
     48 
     49 ```
     50 galileo galilei was an italian physicist, mathematician, astronomer
     51 ```
     52 
     53 Input
     54 
     55 ```
     56 galileo  was  born  in  pisa
     57 ```
     58 
     59 Output
     60 
     61 ```
     62 galileo was born in pisa
     63 ```