Trianglane
InterviewTime limit1sMemory limit1024 MB
Given a two-row strip of unit triangles, each marked black or white, find the perimeter of the black region in meters.
- Level
Easy3 of 10
- Topics
- Implementation, Simulation
- Solved
- No attempts yet
Problem
Bocchi the Builder has just finished constructing her latest project: a pathway made of two rows of white equilateral triangular tiles. However, at the last moment, disaster struck, and she accidentally spilled black paint on some of the tiles. Now she must buy warning tape to block off the wet areas. Can you help her determine how many meters of tape she needs?
The first triangle always points upward, and any two adjacent tiles (tiles that share a side) point in opposite directions. Every triangle has a side length of 1 meter.
Input
The first line contains one integer , the number of columns.
The next two lines each contain integers separated by spaces. Each integer gives the color of a tile, where 1 means the tile is black and 0 means the tile is white.
Output
Output a single integer, the length of tape Bocchi must buy in meters.