# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
293665 | BThero | Cultivation (JOI17_cultivation) | C++17 | 1535 ms | 384 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
// chrono::system_clock::now().time_since_epoch().count()
#include<bits/stdc++.h>
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
#define all(x) (x).begin(), (x).end()
#define debug(x) cerr << #x << " = " << x << endl;
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
int cnt[45][45];
pii arr[305];
int n, R, C;
void solve() {
scanf("%d %d", &R, &C);
scanf("%d", &n);
for (int i = 1; i <= n; ++i) {
scanf("%d %d", &arr[i].fi, &arr[i].se);
}
int ans = R + C;
for (int ax = 0; ax <= R; ++ax) {
for (int bx = 0; ax + bx <= R; ++bx) {
for (int ay = 0; ay <= C; ++ay) {
for (int by = 0; ay + by <= C; ++by) {
int cur = ax + bx + ay + by;
if (cur >= ans) {
continue;
}
for (int i = 1; i <= n; ++i) {
int x1 = max(1, arr[i].fi - ax);
int x2 = min(R, arr[i].fi + bx);
int y1 = max(1, arr[i].se - ay);
int y2 = min(C, arr[i].se + by);
cnt[x1][y1]++;
cnt[x2 + 1][y1]--;
cnt[x1][y2 + 1]--;
cnt[x2 + 1][y2 + 1]++;
}
bool ok = 1;
for (int x = 1; x <= R; ++x) {
for (int y = 1; y <= C; ++y) {
cnt[x][y] += cnt[x - 1][y];
cnt[x][y] += cnt[x][y - 1];
cnt[x][y] -= cnt[x - 1][y - 1];
ok &= (cnt[x][y] > 0);
}
}
for (int x = 1; x <= R; ++x) {
for (int y = 1; y <= C; ++y) {
cnt[x][y] = 0;
}
}
if (ok) {
ans = cur;
}
}
}
}
}
printf("%d\n", ans);
}
int main() {
int tt = 1;
while (tt--) {
solve();
}
return 0;
}
컴파일 시 표준 에러 (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... |