A923 | Modern Art--Bronze
来源USACO
时间限制1s
内存限制128MB
通过 / 提交0/0
题目描述
Art critics worldwide have only recently begun to recognize the creative
genius behind the great bovine painter, Picowso.
Picowso paints in a very particular way. She starts with an $N \times N$ blank
canvas, represented by an $N \times N$ grid of zeros, where a zero indicates
an empty cell of the canvas. She then draws $N^2$ rectangles on the canvas,
one in each of $N^2$ colors (conveniently numbered $1 \ldots N^2$). For
example, she might start by painting a rectangle in color 2, giving this
intermediate canvas:
2 2 2 0
2 2 2 0
2 2 2 0
0 0 0 0
She might then paint a rectangle in color 7:
2 2 2 0
2 7 7 7
2 7 7 7
0 0 0 0
And then she might paint a small rectangle in color 3:
2 2 3 0
2 7 3 7
2 7 7 7
0 0 0 0
Each rectangle has sides parallel to the edges of the canvas, and a rectangle
could be as large as the entire canvas or as small as a single cell. Each
color from $1 \ldots N^2$ is used exactly once, although later colors might
completely cover up some of the earlier colors.
Given the final state of the canvas, please count how many of the $N^2$ colors
could have possibly been the first to be painted.
genius behind the great bovine painter, Picowso.
Picowso paints in a very particular way. She starts with an $N \times N$ blank
canvas, represented by an $N \times N$ grid of zeros, where a zero indicates
an empty cell of the canvas. She then draws $N^2$ rectangles on the canvas,
one in each of $N^2$ colors (conveniently numbered $1 \ldots N^2$). For
example, she might start by painting a rectangle in color 2, giving this
intermediate canvas:
2 2 2 0
2 2 2 0
2 2 2 0
0 0 0 0
She might then paint a rectangle in color 7:
2 2 2 0
2 7 7 7
2 7 7 7
0 0 0 0
And then she might paint a small rectangle in color 3:
2 2 3 0
2 7 3 7
2 7 7 7
0 0 0 0
Each rectangle has sides parallel to the edges of the canvas, and a rectangle
could be as large as the entire canvas or as small as a single cell. Each
color from $1 \ldots N^2$ is used exactly once, although later colors might
completely cover up some of the earlier colors.
Given the final state of the canvas, please count how many of the $N^2$ colors
could have possibly been the first to be painted.
输入格式
The first line of input contains $N$, the size of the canvas ($1 \leq N \leq
1000$). The next $N$ lines describe the final picture of the canvas, each
containing $N$ integers that are in the range $0 \ldots N^2$. The input is
guaranteed to have been drawn as described above, by painting successive
rectangles in different colors.
1000$). The next $N$ lines describe the final picture of the canvas, each
containing $N$ integers that are in the range $0 \ldots N^2$. The input is
guaranteed to have been drawn as described above, by painting successive
rectangles in different colors.
输出格式
Please output a count of the number of colors that could have been drawn
first.
first.
输入输出样例
输入 #1
4 2 2 3 0 2 7 3 7 2 7 7 7 0 0 0 0
输出 #1
14
In this example, color 2 could have been the first to be painted. Color 3
clearly had to have been painted after color 7, and color 7 clearly had to
have been painted after color 2. Since we don't see the other colors, we
deduce that they also could have been painted first.
clearly had to have been painted after color 7, and color 7 clearly had to
have been painted after color 2. Since we don't see the other colors, we
deduce that they also could have been painted first.
C++ 编辑器
输入
输出
可保存默认模板;新题优先使用已保存模板。
当前快捷键仅展示,暂不支持修改。
- 撤销
Ctrl / ⌘ + Z - 重做
Ctrl / ⌘ + Y - 查找
Ctrl / ⌘ + F - 全选
Ctrl / ⌘ + A - 复制
Ctrl / ⌘ + C - 剪切
Ctrl / ⌘ + X - 粘贴
Ctrl / ⌘ + V - 自动排版
工具栏排版按钮 - 草稿保存
编辑时自动保存到本机
历史
提交记录
状态说明时间源码
AI
作答助手
你好,我是作答助手。可以问思路、复杂度、样例含义或代码报错原因;不会直接给出完整 AC 代码。
确定要清空代码吗?
提交通过
评测结果:Accepted