{"problem":{"name":"B. Spotlights","description":{"content":"Theater stage is a rectangular field of size _n_ × _m_. The director gave you the stage's plan which actors will follow. For each cell it is stated in the plan if there would be an actor in this cell ","description_type":"Markdown"},"platform":"Codeforces","limit":{"time_limit":1000,"memory_limit":262144},"difficulty":"None","is_remote":true,"is_sync":true,"sync_url":null,"sign":"CF738B"},"statements":[{"statement_type":"Markdown","content":"Theater stage is a rectangular field of size _n_ × _m_. The director gave you the stage's plan which actors will follow. For each cell it is stated in the plan if there would be an actor in this cell or not.\n\nYou are to place a spotlight on the stage in some _good_ position. The spotlight will project light in one of the four directions (if you look at the stage from above) — left, right, up or down. Thus, the spotlight's position is a cell it is placed to and a direction it shines.\n\nA position is _good_ if two conditions hold:\n\n*   there is no actor in the cell the spotlight is placed to;\n*   there is at least one actor in the direction the spotlight projects.\n\nCount the number of _good_ positions for placing the spotlight. Two positions of spotlight are considered to be different if the location cells or projection direction differ.\n\n## Input\n\nThe first line contains two positive integers _n_ and _m_ (1 ≤ _n_, _m_ ≤ 1000) — the number of rows and the number of columns in the plan.\n\nThe next _n_ lines contain _m_ integers, 0 or 1 each — the description of the plan. Integer 1, means there will be an actor in the corresponding cell, while 0 means the cell will remain empty. It is guaranteed that there is at least one actor in the plan.\n\n## Output\n\nPrint one integer — the number of _good_ positions for placing the spotlight.\n\n[samples]\n\n## Note\n\nIn the first example the following positions are _good_:\n\n1.  the (1, 1) cell and right direction;\n2.  the (1, 1) cell and down direction;\n3.  the (1, 3) cell and left direction;\n4.  the (1, 3) cell and down direction;\n5.  the (1, 4) cell and left direction;\n6.  the (2, 2) cell and left direction;\n7.  the (2, 2) cell and up direction;\n8.  the (2, 2) and right direction;\n9.  the (2, 4) cell and left direction.\n\nTherefore, there are 9 _good_ positions in this example.","is_translate":false,"language":"English"},{"statement_type":"Markdown","content":"剧院舞台是一个大小为 $n × m$ 的矩形区域。导演给你了一份演员移动的计划，其中每个格子都标明了是否会有演员在该位置。\n\n你需要在舞台上放置一盏聚光灯在某个 _良好_ 的位置。聚光灯将朝四个方向之一（从上方观察舞台）投射光线——左、右、上或下。因此，聚光灯的位置由它所放置的格子和它照射的方向共同决定。\n\n一个位置是 _良好_ 的，当且仅当满足以下两个条件：\n\n请计算可以放置聚光灯的 _良好_ 位置数量。两个聚光灯位置被视为不同，当且仅当它们所在的格子或投射方向不同。\n\n第一行包含两个正整数 $n$ 和 $m$（$1 ≤ n, m ≤ 1000$）——计划的行数和列数。\n\n接下来的 $n$ 行，每行包含 $m$ 个整数，每个为 $0$ 或 $1$，描述计划。整数 $1$ 表示对应格子有演员，$0$ 表示该格子为空。保证计划中至少有一个演员。\n\n请输出一个整数——可以放置聚光灯的 _良好_ 位置数量。\n\n在第一个例子中，以下位置是 _良好_ 的：\n\n因此，本例中有 $9$ 个 _良好_ 位置。\n\n## Input\n\n第一行包含两个正整数 $n$ 和 $m$（$1 ≤ n, m ≤ 1000$）——计划的行数和列数。接下来的 $n$ 行，每行包含 $m$ 个整数，每个为 $0$ 或 $1$，描述计划。整数 $1$ 表示对应格子有演员，$0$ 表示该格子为空。保证计划中至少有一个演员。\n\n## Output\n\n请输出一个整数——可以放置聚光灯的 _良好_ 位置数量。\n\n[samples]\n\n## Note\n\n在第一个例子中，以下位置是 _良好_ 的：格子 (1, 1) 且方向为右；格子 (1, 1) 且方向为下；格子 (1, 3) 且方向为左；格子 (1, 3) 且方向为下；格子 (1, 4) 且方向为左；格子 (2, 2) 且方向为左；格子 (2, 2) 且方向为上；格子 (2, 2) 且方向为右；格子 (2, 4) 且方向为左。因此，本例中有 $9$ 个 _良好_ 位置。","is_translate":true,"language":"Chinese"}],"meta":{"iden":"CF738B","tags":["brute force","dp","implementation"],"sample_group":[["2 4\n0 1 0 0\n1 0 1 0","9"],["4 4\n0 0 0 0\n1 0 0 1\n0 1 1 0\n0 1 0 0","20"]],"created_at":"2026-03-03 11:00:39"}}