# | TimeUTC-0 | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
223356 | MrDomino | Rectangles (IOI19_rect) | C++14 | 2115 ms | 378196 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.
/// Just checking if this dudes solution works
/*
IOI 19-rect
editorial: https://ioinformatics.org/page/ioi-2019/51
Basically, we compute using stacks the closest value to each square (i, j) such that it's bigger than value on (i, j) on up, down, left and right.
Then we will use the values computed at the previous step to turn the valid squares into valid lines/columns and we are going to check each pair
using brute force(there are about O(n^2) possible pairs).
*/
#include "rect.h"
#include<bits/stdc++.h>
using namespace std;
int maxst[2502][2502], maxdr[2502][2502], maxup[2502][2502], maxdwn[2502][2502];
int upleft[2502][2502], downleft[2502][2502], leftup[2502][2502], rightup[2502][2502];
vector<long long> v;
void check(int xa, int xb, int ya, int yb)
{
if(xb < xa || yb < ya)
return;
if(!((maxdr[xb][ya-1]-1 == yb && rightup[xb][ya-1] <= xa) || (maxst[xb][yb+1]+1 == ya && leftup[xb][yb+1] <= xa)))
return;
if(!((maxdwn[xa-1][yb]-1 == xb && downleft[xa-1][yb] <= ya) || (maxup[xb+1][yb]+1 == xa && upleft[xb+1][yb] <= ya)))
return;
v.push_back(((1LL * xa * 3010 + xb) * 3010 + ya) * 3010 + yb);
}
long long count_rectangles(vector<vector<int> > a)
{
int n = a.size();
int m = a[0].size();
long long ans = 0;
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |