{"problem":{"name":"[SDCPC 2023] Puzzle: Sashigane","description":{"content":"Given a grid with $n$ rows and $n$ columns, there is exactly one black cell in the grid and all other cells are white. Let $(i, j)$ be the cell on the $i$-th row and the $j$-th column, this black cell","description_type":"Markdown"},"platform":"Luogu","limit":{"time_limit":1000,"memory_limit":1048576},"difficulty":{"LuoguStyle":"P3"},"is_remote":true,"is_sync":true,"sync_url":null,"sign":"LGP9567"},"statements":[{"statement_type":"Markdown","content":"Given a grid with $n$ rows and $n$ columns, there is exactly one black cell in the grid and all other cells are white. Let $(i, j)$ be the cell on the $i$-th row and the $j$-th column, this black cell is located at $(b_i, b_j)$.\n\nYou need to cover all white cells with some L-shapes, so that each white cell is covered by exactly one L-shape and the only black cell is not covered by any L-shape. L-shapes must not exceed the boundary of the grid.\n\nMore formally, an L-shape in the grid is uniquely determined by four integers $(r, c, h, w)$, where $(r, c)$ determines the turning point of the L-shape, and $h$ and $w$ determine the direction and lengths of the two arms of the L-shape. The four integers must satisfy $1 \\le r, c \\le n$, $1 \\le r + h \\le n$, $1 \\le c + w \\le n$, $h \\ne 0$, $w \\ne 0$.\n\n- If $h < 0$, then all cells $(i, c)$ satisfying $r + h \\le i \\le r$ belong to this L-shape; Otherwise if $h > 0$, all cells $(i, c)$ satisfying $r \\le i \\le r + h$ belong to this L-shape.\n- If $w < 0$, then all cells $(r, j)$ satisfying $c + w \\le j \\le c$ belong to this L-shape; Otherwise if $w > 0$, all cells $(r, j)$ satisfying $c \\le j \\le c + w$ belong to this L-shape.\n\nThe following image illustrates some L-shapes.\n\n![](https://cdn.luogu.com.cn/upload/image_hosting/s4jgji61.png)\n\n## Input\n\nThere is only one test case in each test file.\n\nThe first line contains three integers $n$, $b_i$ and $b_j$ ($1 \\le n \\le 10^3$, $1 \\le b_i, b_j \\le n$) indicating the size of the grid and the position of the black cell.\n\n## Output\n\nIf a valid answer exists first output `Yes` in the first line, then in the second line output an integer $k$ ($0 \\leq k \\leq \\frac{n^2-1}{3}$) indicating the number of L-shapes to cover white cells. Then output $k$ lines where the $i$-th line contains four integers $r_i$, $c_i$, $h_i$, $w_i$ separated by a space indicating that the $i$-th L-shape is uniquely determined by $(r_i, c_i, h_i, w_i)$. If there are multiple valid answers you can print any of them.\n\nIf there is no valid answer, just output `No` in one line.\n\n[samples]\n\n## Note\n\nWe illustrate the first sample test case as follows.\n\n![](https://cdn.luogu.com.cn/upload/image_hosting/nbrr3gun.png)","is_translate":false,"language":"English"}],"meta":{"iden":"LGP9567","tags":["2023","山东","Special Judge","O2优化","构造","省赛/邀请赛"],"sample_group":[["5 3 4\n","Yes\n6\n5 1 -1 3\n1 2 1 3\n3 1 -2 1\n4 3 -1 -1\n4 5 1 -1\n2 5 1 -2\n"],["1 1 1\n","Yes\n0\n"]],"created_at":"2026-03-03 11:09:25"}}