이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
/**
____ ____ ____ __________________ ____ ____ ____
||I || ||c || ||e || || || ||M || ||a || ||n ||
||__|| ||__|| ||__|| ||________________|| ||__|| ||__|| ||__||
|/__\| |/__\| |/__\| |/________________\| |/__\| |/__\| |/__\|
*/
#include <iostream>
#include <chrono>
#include "quality.h"
#define maxn 3005
#define maxlog 20
#define INF 1000000010
#define LINF 1000000000000000005
#define endl '\n'
#define pb(x) push_back(x)
#define X first
#define Y second
#define control cout<<"passed"<<endl;
#pragma GCC optimize("O3" , "Ofast" , "unroll-loops" , "fast-math")
#pragma GCC target("avx2")
using namespace std;
typedef unsigned long long ull;
typedef pair <int, int> pii;
typedef long long ll;
typedef pair <ll, ll> pll;
typedef pair <int, ll> pil;
typedef pair <ll, int> pli;
typedef long double pd;
std::chrono::high_resolution_clock::time_point startT, currT;
constexpr double TIME_MULT = 1;
double timePassed()
{
using namespace std::chrono;
currT = high_resolution_clock::now();
double time = duration_cast<duration<double>>(currT - startT).count();
return time * TIME_MULT;
}
int pref[maxn][maxn];
int a[maxn][maxn];
int n, m, h, w;
bool check(int x)
{
for(int i = 1; i <= n; i++)
for(int j = 1; j <= m; j++)
{
pref[i][j] = 0;
pref[i][j] = pref[i][j - 1] + pref[i - 1][j] - pref[i - 1][j - 1];
if(x >= a[i][j])
pref[i][j]++;
}
for(int i = 1; i <= n; i++)
for(int j = 1; j <= m; j++)
if(i - h >= 0 && j - w >= 0)
{
int pom = pref[i][j] + pref[i - h][j - w] - pref[i - h][j] - pref[i][j - w];
if(pom * 2 >= h * w)
return true;
}
return false;
}
int rectangle(int R, int C, int H, int W, int Q[3001][3001])
{
n = R;
m = C;
h = H;
w = W;
for(int i = 1; i <= n; i++)
for(int j = 1; j <= m; j++)
a[i][j] = Q[i - 1][j - 1];
int l = 1, r = n * m;
int ans = 0;
while(l < r)
{
int mid = (l + r) / 2;
if(check(mid) == true)
r = mid;
else
l = mid + 1;
}
return l;
}
/**int main()
{
#ifdef ONLINE_JUDGE /// promeni
freopen("taxi.in", "r", stdin);
freopen("taxi.out", "w", stdout);
#endif
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
startT = std::chrono::high_resolution_clock::now();
read();
solve();
return 0;
}
*/
컴파일 시 표준 에러 (stderr) 메시지
quality.cpp: In function 'int rectangle(int, int, int, int, int (*)[3001])':
quality.cpp:94:9: warning: unused variable 'ans' [-Wunused-variable]
94 | int ans = 0;
| ^~~
# | 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... |