codeforces-scrape

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

982A.md (1447B)


      1 Source: https://codeforces.com/problemset/problem/982/A
      2 
      3 A. Row
      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 You're given a row with $n$ chairs. We call a seating of people "maximal" if the two following conditions hold:
     22 
     23 1. There are no neighbors adjacent to anyone seated.
     24 2. It's impossible to seat one more person without violating the first rule.
     25 
     26 The seating is given as a string consisting of zeros and ones ($0$ means that the corresponding seat is empty, $1$ — occupied). The goal is to determine whether this seating is "maximal".
     27 
     28 Note that the first and last seats are not adjacent (if $n \ne 2$).
     29 
     30 Input
     31 
     32 The first line contains a single integer $n$ ($1 \leq n \leq 1000$) — the number of chairs.
     33 
     34 The next line contains a string of $n$ characters, each of them is either zero or one, describing the seating.
     35 
     36 Output
     37 
     38 Output "Yes" (without quotation marks) if the seating is "maximal". Otherwise print "No".
     39 
     40 You are allowed to print letters in whatever case you'd like (uppercase or lowercase).
     41 
     42 Examples
     43 
     44 Input
     45 
     46 ```
     47 3  
     48 101
     49 ```
     50 
     51 Output
     52 
     53 ```
     54 Yes
     55 ```
     56 
     57 Input
     58 
     59 ```
     60 4  
     61 1011
     62 ```
     63 
     64 Output
     65 
     66 ```
     67 No
     68 ```
     69 
     70 Input
     71 
     72 ```
     73 5  
     74 10001
     75 ```
     76 
     77 Output
     78 
     79 ```
     80 No
     81 ```
     82 
     83 Note
     84 
     85 In sample case one the given seating is maximal.
     86 
     87 In sample case two the person at chair three has a neighbour to the right.
     88 
     89 In sample case three it is possible to seat yet another person into chair three.