CCC '23 S1 - Trianglane

View as PDF

Submit solution


Points: 5 (partial)
Time limit: 1.0s
Memory limit: 1G

Author:
Problem type
Canadian Computing Competition: 2023 Stage 1, Junior #4, Senior #1

Bocchi the Builder has just finished constructing her latest project: a pathway consisting 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 purchase warning tape to block off the wet areas. Can you help her determine how many meters of tape she needs?

The first triangle will always point upwards, and any pair of adjacent tiles (that is, tiles that share a common side) will point in opposite directions. Every triangle has a side length of 1 meter.

Input Specification

The first line will consist of one integer, C, representing the number of columns.

The next two lines will each consist of C integers separated by spaces. Each integer represents the colour of a tile in the room, with 1 indicating that the tile is black and 0 indicating that the tile is white.

The following table shows how the available 15 marks are distributed:

Marks Awarded Bounds on C Additional Constraints
3 marks 1 \le C \le 2\,000 Black tiles will never be adjacent and the second row is fully white.
3 marks 1 \le C \le 2\,000 The second row is fully white.
5 marks 1 \le C \le 2\,000 None
4 marks 1 \le C \le 200\,000 None

Output Specification

Output a single integer representing the length of the tape Bocchi must purchase in meters.

Sample Input 1

5
1 0 1 0 1
0 0 0 0 0

Output for Sample Input 1

9

Explanation of Output for Sample Input 1

The tiles are painted as follows, with the warning tape highlighted in yellow.

Sample Input 2

7
0 0 1 1 0 0 0
0 0 1 0 1 0 0

Output for Sample Input 2

8

Explanation of Output for Sample Input 2

The tiles are painted as follows, with the warning tape highlighted in yellow.


Comments

Comments are disabled on this page.

  • 34
    wleung_bvg  commented on March 4, 2023, 6:15 a.m.

    comments are locked on ccc how


  • 46
    Triple_Edged  commented on Feb. 18, 2023, 3:07 a.m.

    bocchi the rock on ccc how


  • 43
    7kxb  commented on Feb. 18, 2023, 2:55 a.m.

    i love bocchi the rock


    • 19
      otikki  commented on Feb. 21, 2023, 7:08 p.m.

      anime of the year 😎👍


  • 46
    psun256  commented on Feb. 18, 2023, 2:33 a.m.

    bocchi the rock on ccc how


    • 28
      ThePeeps191  commented on Feb. 26, 2023, 5:08 p.m.

      bocchi the rock on ccc how


    • 35
      Potatoritos  commented on Feb. 18, 2023, 4:24 a.m.

      bocchi the rock on ccc how


    • 35
      Bill_Skills  commented on Feb. 18, 2023, 2:56 a.m.

      bocchi the rock on ccc how


    • 37
      Vertiqo  commented on Feb. 18, 2023, 2:34 a.m.

      bocchi the rock on ccc how


      • 28
        oxymorontranses  commented on Feb. 20, 2023, 11:58 a.m.

        bocchi the rock on ccc how


        • 28
          kevin_huang4307  commented on Feb. 20, 2023, 11:54 p.m.

          bocchi the rock on ccc how


          • 28
            LMeister  commented on Feb. 21, 2023, 7:10 p.m.

            bocchi the rock on ccc how


            • 27
              CodingCrab_520  commented on Feb. 22, 2023, 11:24 p.m.

              bocchi the rock on ccc how


              • 28
                III  commented on Feb. 26, 2023, 5:15 p.m.

                bocchi the rock on ccc how


                • 28
                  nexus257  commented on Feb. 28, 2023, 5:05 p.m.

                  bocchi the rock on ccc how


                  • 28
                    Zsabel  commented on March 2, 2023, 2:36 a.m.

                    bocchi the rock on ccc how


  • -45
    darthjarjarjarjar  commented on Feb. 18, 2023, 12:08 a.m.

    This comment is hidden due to too much negative feedback. Show it anyway.


    • 40
      slurp  commented on Feb. 18, 2023, 3:00 a.m.

      boccher