| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
|---|---|---|---|---|---|---|---|
| 729483 | MilosMilutinovic | Rectangles (IOI19_rect) | C++14 | 0 ms | 0 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
// todo
#include "rect.h"
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i ++)
#define rep1(i, n) for(int i = 1; i <= (int)(n); i ++)
#define MP make_pair
using namespace std;
typedef long long LL;
typedef pair<int, int> PII;
PII goL[2505][2505], goR[2505][2505], goU[2505][2505], goD[2505][2505];
vector<PII> ver[2505], hor[2505];
LL count_rectangles(vector<vector<int>> a)
{
int n = (int)a.size(), m = (int)a[0].size();
rep(i, n) {
vector<int> stk;
rep(j, m) {
while(!stk.empty() && a[i][j] > a[i][stk.back()]) stk.pop_back();
goL[i][j] = MP(i, stk.empty() ? -1 : stk.back());
stk.push_back(j);
}
}
rep(i, n) {
vector<int> stk;
for(int j = m - 1; j >= 0; j--) {
while(!stk.empty() && a[i][j] > a[i][stk.back()]) stk.pop_back();
goR[i][j] = MP(i, stk.empty() ? -1 : stk.back());
stk.push_back(j);
}
}
rep(j, m) {
vector<int> stk;
rep(i, n) {
while(!stk.empty() && a[i][j] > a[stk.back()][j]) stk.pop_back();
goU[i][j] = MP(stk.empty() ? -1 : stk.back(), j);
stk.push_back(i);
}
}
rep(j, m) {
vector<int> stk;
for(int i = n - 1; i >= 0; i--) {
while(!stk.empty() && a[i][;j] > a[stk.back()][j]) stk.pop_back();
goD[i][j] = MP(stk.back() ? -1 : stk.back(), j);
stk.push_back(i);
}
}
rep(i, n) rep(j, m) {
if(goL[i][j].second != -1) ver[i].push_back(MP(goL[i][j].second, j));
if(goR[i][j].second != -1) ver[i].push_back(MP(j, goR[i][j].second));
}
}
