{"problem":{"name":"01 Matrix","description":{"content":"We have a square grid with $H$ rows and $W$ columns. Snuke wants to write $0$ or $1$ in each of the squares. Here, all of the following conditions have to be satisfied: *   For every row, the smaller","description_type":"Markdown"},"platform":"AtCoder","limit":{"time_limit":2000,"memory_limit":262144},"difficulty":"None","is_remote":true,"is_sync":true,"sync_url":null,"sign":"agc038_a"},"statements":[{"statement_type":"Markdown","content":"We have a square grid with $H$ rows and $W$ columns. Snuke wants to write $0$ or $1$ in each of the squares. Here, all of the following conditions have to be satisfied:\n\n*   For every row, the smaller of the following is $A$: the number of $0$s contained in the row, and the number of $1$s contained in the row. (If these two numbers are equal, “the smaller” should be read as “either”.)\n*   For every column, the smaller of the following is $B$: the number of $0$s contained in the column, and the number of $1$s contained in the column.\n\nDetermine if these conditions can be satisfied by writing $0$ or $1$ in each of the squares. If the answer is yes, show one way to fill the squares so that the conditions are satisfied.\n\n## Constraints\n\n*   $1 \\leq H,W \\leq 1000$\n*   $0 \\leq A$\n*   $2 \\times A \\leq W$\n*   $0 \\leq B$\n*   $2 \\times B \\leq H$\n*   All values in input are integers.\n\n## Input\n\nInput is given from Standard Input in the following format:\n\n$H$ $W$ $A$ $B$\n\n[samples]","is_translate":false,"language":"English"}],"meta":{"iden":"agc038_a","tags":[],"sample_group":[["3 3 1 1","100\n010\n001\n\nEvery row contains two $0$s and one $1$, so the first condition is satisfied. Also, every column contains two $0$s and one $1$, so the second condition is satisfied."],["1 5 2 0","01010"]],"created_at":"2026-03-03 11:01:14"}}