Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Just some hints..</p> <p>You could impose better restrictions on the values. The requirement leads to condition </p> <p><code>N1*(k+1) == S*k</code>, where <code>N1</code> is number of ones in an area, and <code>S=dx*dy</code> is its surface. It can be rewritten in better form:</p> <p><code>N1/k == S/(k+1)</code>. </p> <p>Because the greatest common divisor of numbers <code>n</code> and <code>n+1</code> is always 1, then <code>N1</code> have to be multiple of <code>k</code> and <code>dx*dy</code> to be multiple of <code>k+1</code>. It reduces greatly the possible space of solutions, the larger is <code>k</code>, the better (for <code>dx*dy</code> case you'll need to play with prime divisors of <code>k+1</code>).</p> <p>Now, because you need just the surface of the largest area with such property, it would be wise to start from largest areas and move to smaller ones. By trying <code>dx*dy</code> from <code>n^2</code> downto <code>k+1</code> that would satisfy the divisor and the bounding conditions, you'll find quite fast the solution, muuuch faster than O(n^4), because of a special reason: except cases when the array was specially constructed, if we assume a random input, the probability that there are <code>N1</code> ones out of <code>S</code> values in the <code>(n-dx+1)*(n-dy+1)</code> areas that have the surface <code>S</code> will constantly grow with decrease of <code>S</code>. (large values of <code>k</code> will make the probability smaller, but in the same time they will make the filter for <code>dx</code> and <code>dy</code> pairs stronger).</p> <p>Also, this problem: <a href="http://ioinformatics.org/locations/ioi99/contest/land/land.shtml" rel="nofollow noreferrer">http://ioinformatics.org/locations/ioi99/contest/land/land.shtml</a> , looks somehow similar, maybe you'll find some ideas in their solution.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload