codeforces-scrape

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

825A.md (1199B)


      1 Source: https://codeforces.com/problemset/problem/825/A
      2 
      3 A. Binary Protocol
      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 Polycarp has just invented a new binary protocol for data transmission. He is encoding positive integer decimal number to binary string using following algorithm:
     22 
     23 * Each digit is represented with number of '1' characters equal to the value of that digit (for 0 it is zero ones).
     24 * Digits are written one by one in order corresponding to number and separated by single '0' character.
     25 
     26 Though Polycarp learnt how to encode the numbers, he has no idea how to decode them back. Help him calculate the decoded number.
     27 
     28 Input
     29 
     30 The first line contains one integer number *n* (1 ≤ *n* ≤ 89) — length of the string *s*.
     31 
     32 The second line contains string *s* — sequence of '0' and '1' characters, number in its encoded format. It is guaranteed that the number corresponding to the string is positive and doesn't exceed 109. The string always starts with '1'.
     33 
     34 Output
     35 
     36 Print the decoded number.
     37 
     38 Examples
     39 
     40 Input
     41 
     42 ```
     43 3  
     44 111
     45 ```
     46 
     47 Output
     48 
     49 ```
     50 3
     51 ```
     52 
     53 Input
     54 
     55 ```
     56 9  
     57 110011101
     58 ```
     59 
     60 Output
     61 
     62 ```
     63 2031
     64 ```