QOJ.ac

QOJ

Límite de tiempo: 2 s Límite de memoria: 1024 MB Puntuación total: 100

#10228. Painting the perfect art

Estadísticas

Following Jackson Pollock and Clyfford Still, Adam decided to create some abstract art. He decided to start simple: paint a picture consisting of three stars.

Adam bought a piece of exquisite paper, which can be viewed as a grid consisting of $n$ rows and $m$ columns. Adam has specified some cells that are suitable for painting stars.

Since the paper is large, Adam needs to first cut out the part needed for the painting. It can be any sub-rectangle of the grid. Formally, for integers $x_1, x_2, y_1, y_2$, if $0 \le x_1 \le x_2 < n$ and $0 \le y_1 \le y_2 < m$, the cells with row indices in $[x_1, x_2]$ and column indices in $[y_1, y_2]$ form a sub-rectangle. These are all the possible sub-rectangles. Then, Adam needs to find three distinct cells within the sub-rectangle to paint the stars. Of course, these cells must be specified as suitable for painting stars.

Adam wants to know how many ways he can create such an artwork. Since this number can be quite large, you only need to output the result modulo $10^9+7$.

Implementation Details

You should include art.h and implement the following procedure:

int count(bool[][] v)

  • $v$: A 2D array of size $n \times m$. For each $i, j$ ($0 \le i \le n-1$, $0 \le j \le m-1$), $v[i][j]=1$ if the cell at row $i$ and column $j$ is suitable for painting a star, otherwise $v[i][j]=0$.
  • The procedure you implement will be called exactly once.
  • You should return the number of ways to create the artwork modulo $10^9+7$: an integer in the range $[0, 10^9+6]$.

Examples

Example 1

Consider the call: count([[1,1,0],[1,0,0]])

We can only paint stars in the three available cells, and there are two different sub-rectangles that contain these three stars. Therefore, there are two different ways to create the artwork, and a correct program should return $2$.

Constraints

$1 \le n, m \le 3000$

Subtasks

  1. (20 points) $n, m \le 80$
  2. (20 points) $n, m \le 300$
  3. (20 points) All cells are suitable for painting stars.
  4. (40 points) No special restrictions.

Sample Grader

The sample grader reads the input in the following format:

  • First line: $n~m$
  • Next $n$ lines, each containing $m$ characters (0 or 1), describing $v$

The sample grader prints your output in the following format:

  • One line, your return value

Discussions

About Discussions

The discussion section is only for posting: General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.