이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <iostream>
#include <fstream>
#include <string>
#include <cstring>
#include <cstdint>
#include <cstdlib>
#include <cstdio>
#include <cctype>
#include <cmath>
#include <vector>
#include <bitset>
#include <queue>
#include <deque>
#include <stack>
#include <cmath>
#include <tuple>
#include <list>
#include <set>
#include <map>
#define add push_back
#define m_p make_pair
#define fr first
#define sc second
#define endl '\n'
using namespace std;
typedef long long ll;
typedef unsigned long long llu;
typedef long double ld;
typedef pair<ll, ll> pii;
const ll N = 1000005, mod = 998244353, M = 3001;
ll n, m, k, i, j, ans, kaskad[N], matrix[M][M], pref[M][M], h, w;
bool check(ll value)
{
for (int i = 1; i <= n; ++i)
{
for (int j = 1; j <= m; ++j)
{
ll x = -1;
if (matrix[i][j] > value)
x = 1;
else if (matrix[i][j] == value)
x = 0;
pref[i][j] = pref[i - 1][j] + pref[i][j - 1] - pref[i - 1][j - 1] + x;
}
}
for (int i = h; i <= n; ++i)
{
for (int j = w; j <= m; ++j)
{
if (pref[i][j] - pref[i - h][j] - pref[i][j - w] + pref[i - h][j - w] <= 0)
return true;
}
}
return false;
}
void BinarySearch(ll left, ll right)
{
if (right - left <= 1)
return;
ll mid = (left + right) / 2;
if (!check(mid))
{
BinarySearch(mid, right);
}
else
{
ans = mid;
BinarySearch(left, mid);
}
}
int rectangle(int nn, int mm, int hh, int ww, int a[M][M])
{
n = nn;
m = mm;
h = hh;
w = ww;
for (int i = 0; i < n; ++i)
{
for (int j = 0; j < m; ++j)
{
matrix[i + 1][j + 1] = a[i][j];
}
}
BinarySearch(0, n * m);
return ans;
}
# | 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... |