# | TimeUTC-0 | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
204158 | jond98i | Detecting Molecules (IOI16_molecules) | C++14 | 0 ms | 0 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
/*
* Solution to IOI 2009 problem "raisins"
*
* This solution employs memoization in order to compute the the best
* way of cutting any sub-rectangle of the chocolate. To do this
* sufficiently quickly, we also precompute the number of raisins in
* each sub-rectangle subtended from the top-left corner of the chocolate.
*
* This allows us to compute the number of raisins in any rectangular
* sub-region of the chocolate -- consider the diagram below:
*
* (0,0)-------+-------(c,0)
* | A | B |
* +-------(a,b)-------+
* | C | D |
* (0,d)-------+-------(c,d)
*
* Suppose we wish to compute the number of raisins in the region
* (a,b) -> (c,d), D. Now D = (A + B + C + D) - (A + B) - (A + C) + A
* Each of these four quantities is given by the number of raisins
* in a rectangular sub-region whose top-left corner is (0,0).
*
* Carl Hultquist, chultquist@gmail.com
*/
#include <iostream>
#include <cassert>
#include <climits>
#include <cstring>