This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include "quality.h"
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
#define OPTM ios_base::sync_with_stdio(0); cin.tie(0);
#define INF int(1e9+7)
#define ln '\n'
#define ll long long
#define ull unsigned long long
#define ui unsigned int
#define us unsigned short
#define FOR(i,s,n) for (int i = s; i < n; i++)
#define FORR(i,n,s) for (int i = n; i > s; i--)
#define FORX(u, arr) for (auto u : arr)
#define PB push_back
#define in(v,x) (v.find(x) != v.end())
#define F first
#define S second
#define PII pair<int, int>
#define PLL pair<ll, ll>
#define UM unordered_map
#define US unordered_set
#define PQ priority_queue
#define ALL(v) v.begin(), v.end()
const ll LLINF = 1e18+1;
const int MAXN = 3e3+1;
int g[MAXN][MAXN];
ordered_set s;
int r,c;
void print() {
FOR(k,0,r) {
FOR(l,0,c) {
if (s.find(g[k][l]) != s.end()) cout << 1;
else cout << 0;
}
cout << ln;
}
cout << ln;
}
int rectangle(int R, int C, int h, int w, int G[3001][3001]) {
r = R; c = C;
FOR(i,0,r) FOR(j,0,c) g[i][j] = G[i][j];
int res = INF;
FOR(i,0,h) {
FOR(j,0,w) s.insert(g[i][j]);
}
int idx = h*w/2;
res = *s.find_by_order(idx);
FOR(i,0,r-h+1) {
if (i%2 == 0) {
FOR(j,w,c) {
//print();
FOR(k,i,i+h) {
s.insert(g[k][j]);
s.erase(g[k][j-w]);
}
res = min(res, *s.find_by_order(idx));
}
if (i+h < r) {
//print();
FOR(j,c-w,c) {
s.insert(g[i+h][j]);
s.erase(g[i][j]);
}
res = min(res, *s.find_by_order(idx));
}
}
else {
FORR(j,c-1,w-1) {
//print();
FOR(k,i,i+h) {
s.insert(g[k][j-w]);
s.erase(g[k][j]);
}
res = min(res, *s.find_by_order(idx));
}
if (i+h < r) {
//print();
FOR(j,0,w) {
s.insert(g[i+h][j]);
s.erase(g[i][j]);
}
res = min(res, *s.find_by_order(idx));
}
}
}
return res;
}
# | 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... |