# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
21593 | kingpig9 | Cultivation (JOI17_cultivation) | C++11 | 416 ms | 7240 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
const int MAXN = 310, MAXS = 1e5 + 10;
void setmin (int &a, int b) {
if (a > b) {
a = b;
}
}
void setmax (int &a, int b) {
if (a < b) {
a = b;
}
}
int R, C, N;
int X[MAXN], Y[MAXN];
set<int> sty[MAXS];
int main() {
//monica lewinsky
scanf("%d %d %d", &R, &C, &N);
for (int i = 1; i <= N; i++) {
scanf("%d %d", &X[i], &Y[i]);
}
int ans = INT_MAX;
for (int nup = 0; nup < R; nup++) {
for (int i = 1; i <= R; i++) {
sty[i].clear();
}
for (int i = 1; i <= N; i++) {
for (int x = X[i]; x && x >= X[i] - nup; x--) {
sty[x].insert(Y[i]);
}
}
for (int ndown = 0; ndown < R; ndown++) {
for (int i = 1; i <= N; i++) {
int nx = ndown + X[i];
if (nx <= R) {
sty[nx].insert(Y[i]);
}
}
//ok find the min difference
bool bad = false;
for (int i = 1; i <= R; i++) {
if (sty[i].empty()) {
bad = true;
break;
}
}
if (bad) {
continue;
}
//left or right
int nleft = 0, nright = 0;
for (int i = 1; i <= R; i++) {
setmax(nleft, *sty[i].begin() - 1);
setmax(nright, C - *sty[i].rbegin());
}
int nadd = 0;
for (int i = 1; i <= R; i++) {
for (auto it = sty[i].begin(); next(it) != sty[i].end(); it++) {
int y1 = *it + nright, y2 = *next(it) - nleft;
//how many are between those two
setmax(nadd, y2 - y1 - 1);
}
}
setmin(ans, nup + ndown + nleft + nright + nadd);
}
}
printf("%d\n", ans);
}
컴파일 시 표준 에러 (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... |