## UCC Coding Competition '20 P1 - Snowstorm

View as PDF

Points: 3
Time limit: 1.0s
Memory limit: 64M

Author:
Problem type
Allowed languages
Ada, Assembly, Awk, Brain****, C, C#, C++, COBOL, CommonLisp, D, Dart, F#, Forth, Fortran, Go, Groovy, Haskell, Intercal, Java, JS, Kotlin, Lisp, Lua, Nim, ObjC, OCaml, Octave, Pascal, Perl, PHP, Pike, Prolog, Python, Racket, Ruby, Rust, Scala, Scheme, Sed, Swift, TCL, Text, Turing, VB, Zig

You are the manager of a luxury hotel's guest pool and spa. You want to make sure each guest visiting the pool and spa area can have their own lounge chairs by the poolside to relax in. Your pool is outdoors, and the lounge chairs are placed in a line by the hotel building. Two rows of balconies from the hotel's second and third floors hang over each lounge chair, as shown below (where Bs represent balconies and Cs represent chairs):

B B B B B...
B B B B B...
C C C C C...

A huge snowstorm just hit your hotel, covering some of the balconies with snow and icicles. You have decided that it is not safe to allow a guest to use a lounge chair if either of the two balconies hanging over it is covered in snow and ice.

Please determine how many lounge chairs are safe for use, so you know how many guests you can let into the pool at a time.

#### Input Specification

The input will consist of three lines. The first line contains , the number of lounge chairs you have in a line.

The second line describes the snow and ice conditions on the first row of balconies above the lounge chairs. It contains a string of 0s and 1s. If the th character in the string is a 0, then there is no snow or ice on the first balcony above the th lounge chair. If the th character is a 1, there is unsafe ice or snow on the first balcony above the th lounge chair.

The third line contains a similar string of 0s and 1s, indicating the snow and ice conditions on the second row of balconies above each lounge chair.

#### Output Specification

Please output the number of lounge chairs safe for use (that is, there is no snow or ice on both balconies above the lounge chair).

#### Sample Input

10
0101110101
1101010011

#### Sample Output

2

#### Explanation for Sample Output

There are two safe lounge chairs: the third and the seventh counting from the left. All the other chairs have snow or ice on at least one of the two balconies above it.