{"problem":{"name":"196. Cubical Classroom","description":{"content":"After the COVID-19 pandemic, a school decides to implement serious measures to ensure that students \"socially distance\" from each other. The school has divided each classroom into several squares, usi","description_type":"Markdown"},"platform":"Codeforces","limit":{"time_limit":1000,"memory_limit":262144},"difficulty":"None","is_remote":true,"is_sync":true,"sync_url":null,"sign":"CF10269196"},"statements":[{"statement_type":"Markdown","content":"After the COVID-19 pandemic, a school decides to implement serious measures to ensure that students \"socially distance\" from each other. The school has divided each classroom into several squares, using glass walls, and each student is assigned to a single \"sub-room\" in the classroom.\n\nUnfortunately, this strategy didn't accomodate enough students. To fix this, the school decided to stack several sub-rooms on top of each other, such that the sub-rooms form a cube. In other words, each classroom has $n^3$ sub-rooms, where $n$ is given as input.\n\nSince everything was messed up by the COVID-19 quarantine, the school's classes all contain students of a wide range of ages. A student is called a _leader_ if they're older than all of the students in adjacent sub-rooms, including diagonally (for example, a sub-room in the center of a classroom with $n = 3$ would have 26 adjacent sub-rooms).\n\nThe teacher of the class wants to figure out which students are most likely to cause trouble. The teacher deduces that a student is likely to cause trouble if the following are true:\n\n1. The student is not a leader (at least one student in an adjacent sub-room is older than them or the same age as them)\n\n2. The student doesn't have any leaders in adjacent sub-rooms (including diagonally)\n\nGiven this information, help the teacher find out how many students in the classroom are likely to be troublemakers.\n\nThe first line of input contains a single positive integer $n$: the number of sub-rooms in a single 1D cross-section of the classroom. There are $n^3$ sub-rooms and students in total.\n\nThe next $n$ lines each contain a 2D grid of space-separated integers: the ages of the students in each top-down cross-section of the classroom. Each cross-section will be separated by a new line.\n\nOutput a single integer $k$: the number of potential troublemakers in the 3D classroom.\n\n## Input\n\nThe first line of input contains a single positive integer $n$: the number of sub-rooms in a single 1D cross-section of the classroom. There are $n^3$ sub-rooms and students in total.The next $n$ lines each contain a 2D grid of space-separated integers: the ages of the students in each top-down cross-section of the classroom. Each cross-section will be separated by a new line.\n\n## Output\n\nOutput a single integer $k$: the number of potential troublemakers in the 3D classroom.\n\n[samples]","is_translate":false,"language":"English"},{"statement_type":"Markdown","content":"**Definitions**  \nLet $ n \\in \\mathbb{Z}^+ $ be the side length of the cubic classroom.  \nLet $ A \\in \\mathbb{Z}^{n \\times n \\times n} $ be the 3D array of student ages, where $ A[i][j][k] $ denotes the age of the student in sub-room at coordinates $ (i, j, k) $, with $ i, j, k \\in \\{0, 1, \\dots, n-1\\} $.\n\nFor a sub-room at position $ p = (i, j, k) $, define its **neighborhood** as:  \n$$\n\\mathcal{N}(p) = \\left\\{ (i', j', k') \\in \\{0, \\dots, n-1\\}^3 \\setminus \\{p\\} \\,\\middle|\\, |i - i'| \\leq 1, |j - j'| \\leq 1, |k - k'| \\leq 1 \\right\\}\n$$\n\nA student at $ p $ is a **leader** if:  \n$$\nA[i][j][k] > \\max_{q \\in \\mathcal{N}(p)} A[q]\n$$\n\nA student at $ p $ is a **troublemaker** if:  \n1. $ A[i][j][k] \\leq \\max_{q \\in \\mathcal{N}(p)} A[q] $ (not a leader), and  \n2. $ \\forall q \\in \\mathcal{N}(p), \\; A[q] \\leq A[i][j][k] $ (no leader in neighborhood)\n\n**Constraints**  \n$ 1 \\leq n \\leq 100 $, and $ 1 \\leq A[i][j][k] \\leq 10^9 $\n\n**Objective**  \nCompute the number of positions $ p \\in \\{0, \\dots, n-1\\}^3 $ such that the student at $ p $ is a troublemaker.","is_translate":false,"language":"Formal"}],"meta":{"iden":"CF10269196","tags":[],"sample_group":[],"created_at":"2026-03-03 11:00:39"}}