codeforces-scrape

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

36A.md (1475B)


      1 Source: https://codeforces.com/problemset/problem/36/A
      2 
      3 A. Extra-terrestrial Intelligence
      4 
      5 time limit per test
      6 
      7 2 seconds
      8 
      9 memory limit per test
     10 
     11 64 megabytes
     12 
     13 input
     14 
     15 input.txt
     16 
     17 output
     18 
     19 output.txt
     20 
     21 Recently Vasya got interested in finding extra-terrestrial intelligence. He made a simple extra-terrestrial signals’ receiver and was keeping a record of the signals for *n* days in a row. Each of those *n* days Vasya wrote a 1 in his notebook if he had received a signal that day and a 0 if he hadn’t. Vasya thinks that he has found extra-terrestrial intelligence if there is a system in the way the signals has been received, i.e. if all the intervals between successive signals are equal. Otherwise, Vasya thinks that the signals were sent by some stupid aliens no one cares about. Help Vasya to deduce from the information given by the receiver if he has found extra-terrestrial intelligence or not.
     22 
     23 Input
     24 
     25 The first line contains integer *n* (3 ≤ *n* ≤ 100) — amount of days during which Vasya checked if there were any signals. The second line contains *n* characters 1 or 0 — the record Vasya kept each of those *n* days. It’s guaranteed that the given record sequence contains at least three 1s.
     26 
     27 Output
     28 
     29 If Vasya has found extra-terrestrial intelligence, output YES, otherwise output NO.
     30 
     31 Examples
     32 
     33 Input
     34 
     35 ```
     36 8  
     37 00111000
     38 ```
     39 
     40 Output
     41 
     42 ```
     43 YES
     44 ```
     45 
     46 Input
     47 
     48 ```
     49 7  
     50 1001011
     51 ```
     52 
     53 Output
     54 
     55 ```
     56 NO
     57 ```
     58 
     59 Input
     60 
     61 ```
     62 7  
     63 1010100
     64 ```
     65 
     66 Output
     67 
     68 ```
     69 YES
     70 ```