[BalticOI 2001] Box of Mirrors

Luogu
IDLGP10612
Time1000ms
Memory512MB
DifficultyP6
2001Special Judge构造BalticOI(波罗的海)Ad-hoc
数学家 Andris 有一个小盒子,其底部是 $n\times m$ 的格子,每个格子可以放一面 $45$ 度朝向的镜子。 在盒子的边界,每行每列的两端,有一些孔,光线可以从中射入盒子,也可以射出。 ![](https://cdn.luogu.com.cn/upload/image_hosting/i5gnsp7v.png) ![](https://cdn.luogu.com.cn/upload/image_hosting/1xl9wkfz.png) 如上图所示,从孔 $2$ 射进盒子的光线经过两次反射后又从孔 $7$ 射出。 Andris 想请你设计一个盒子,使得从每个孔射入的光线都会从指定的孔射出。 例如,如果他希望从 $10$ 个孔里射入的光线分别由孔 $9,7,10,8,6,5,2,4,1,3$ 射出,则上图也是一个满足要求的盒子。 注意,孔的编号如图从 $1$ 到 $2\times (n+m)$ 编号。 ## Input 第一行两个整数 $n,m$,表示盒子的大小。 接下来 $2\times (n+m)$ 行,第 $i+1$ 行一个整数 $a_i$,表示从第 $i$ 个孔射入的光线要从第 $a_i$ 个孔中射出。 ## Output 输出一个 $n\times m$ 的矩阵,对于每个位置,$0$ 表示不放镜子,$1$ 表示放镜子,需要满足对应的要求。数据保证一定有解。 [samples] ## Note 对于 $100\%$ 的数据,$1\leq n,m\leq 100$,$1\leq a_i\leq 2\times (n+m)$。
Samples
Input #1
2 3
9
7
10
8
6
5
2
4
1
3
Output #1
0 1 0
0 1 1
API Response (JSON)
{
  "problem": {
    "name": "[BalticOI 2001] Box of Mirrors",
    "description": {
      "content": "数学家 Andris 有一个小盒子,其底部是 $n\\times m$ 的格子,每个格子可以放一面 $45$ 度朝向的镜子。 在盒子的边界,每行每列的两端,有一些孔,光线可以从中射入盒子,也可以射出。 ![](https://cdn.luogu.com.cn/upload/image_hosting/i5gnsp7v.png) ![](https://cdn.luogu.com.cn/uplo",
      "description_type": "Markdown"
    },
    "platform": "Luogu",
    "limit": {
      "time_limit": 1000,
      "memory_limit": 524288
    },
    "difficulty": {
      "LuoguStyle": "P6"
    },
    "is_remote": true,
    "is_sync": true,
    "sync_url": null,
    "sign": "LGP10612"
  },
  "statements": [
    {
      "statement_type": "Markdown",
      "content": "数学家 Andris 有一个小盒子,其底部是 $n\\times m$ 的格子,每个格子可以放一面 $45$ 度朝向的镜子。\n\n在盒子的边界,每行每列的两端,有一些孔,光线可以从中射入盒子,也可以射出。\n\n![](https://cdn.luogu.com.cn/upload/image_hosting/i5gnsp7v.png)\n\n![](https://cdn.luogu.com.cn/uplo...",
      "is_translate": false,
      "language": "English"
    }
  ]
}
Full JSON Raw Segments