{"problem":{"name":"I. Mason's Mark","description":{"content":"You are given a rectangular matrix representing a picture made by Peter. The '#' character represents a black pixel and the '.' character a white pixel. You should count how many stones are on the pic","description_type":"Markdown"},"platform":"Codeforces","limit":{"time_limit":4000,"memory_limit":262144},"difficulty":"None","is_remote":true,"is_sync":true,"sync_url":null,"sign":"CF10246I"},"statements":[{"statement_type":"Markdown","content":"You are given a rectangular matrix representing a picture made by Peter. The '#' character represents a black pixel and the '.' character a white pixel. You should count how many stones are on the picture with the respective letters A, B, and C.\n\nThe first line contains two integers $W$ and $H$. The next $H$ lines each contain a string of length $W$. The strings are composed of '.' and '#'.\n\n*Limits* \n\nThe output should consist of a single line, whose content is three integers $A$, $B$, and $C$ separated with single spaces, indicating the number of stones with the respective marks A, B, and C.\n\n*Sample Explanation*\n\nThere are black pixels forming a letter C. These pixels, however, belong to the region around the stones and do not form a mark since they are not surrounded by white pixels.\n\n## Input\n\nThe first line contains two integers $W$ and $H$. The next $H$ lines each contain a string of length $W$. The strings are composed of '.' and '#'.*Limits*   $7 <= W <= 1000$;  $9 <= H <= 1000$. \n\n## Output\n\nThe output should consist of a single line, whose content is three integers $A$, $B$, and $C$ separated with single spaces, indicating the number of stones with the respective marks A, B, and C.\n\n[samples]\n\n## Note\n\n*Sample Explanation*There are black pixels forming a letter C. These pixels, however, belong to the region around the stones and do not form a mark since they are not surrounded by white pixels.","is_translate":false,"language":"English"},{"statement_type":"Markdown","content":"**Definitions**  \nLet $ W, H \\in \\mathbb{Z}^+ $ denote the width and height of the matrix.  \nLet $ M \\in \\{ \\text{`.`}, \\text{`#`} \\}^{H \\times W} $ be the binary matrix representing the picture, where `#` denotes a black pixel and `.` denotes a white pixel.  \n\nLet $ R \\subseteq \\{ (i,j) \\mid 1 \\le i \\le H, 1 \\le j \\le W \\} $ be the set of all connected components of black pixels under 4-directional connectivity (up, down, left, right).  \n\nFor each connected component $ c \\in R $, define its **bounding box** as the minimal axis-aligned rectangle enclosing all pixels in $ c $.  \n\nDefine a **stone** as a connected component $ c \\in R $ such that:  \n- All pixels in $ c $ are part of a **closed contour** forming one of the letters A, B, or C.  \n- The contour is **fully surrounded by white pixels** (i.e., no black pixel touches the matrix boundary).  \n- The shape of $ c $ matches the topological structure of one of the letters A, B, or C (as defined by standard pixel-based glyph recognition: A has a triangular top and a horizontal bar; B has two half-circles and a vertical bar; C is a concave curve open to the right).  \n\n**Constraints**  \n1. $ 1 \\le W, H \\le 100 $  \n2. Each connected component $ c \\in R $ consists of at least 3 pixels.  \n3. Only components fully enclosed by white pixels (i.e., no pixel in $ c $ is on the matrix boundary) are considered valid stones.  \n\n**Objective**  \nCount the number of valid stone components matching the shapes of letters A, B, and C:  \nLet $ A = |\\{ c \\in R \\mid c \\text{ matches shape A} \\}| $,  \n$ B = |\\{ c \\in R \\mid c \\text{ matches shape B} \\}| $,  \n$ C = |\\{ c \\in R \\mid c \\text{ matches shape C} \\}| $.  \n\nOutput: $ A \\ B \\ C $","is_translate":false,"language":"Formal"}],"meta":{"iden":"CF10246I","tags":[],"sample_group":[],"created_at":"2026-03-03 11:00:39"}}