# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
110480 | tincamatei | Cultivation (JOI17_cultivation) | C++14 | 2039 ms | 384 KiB |
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 <bits/stdc++.h>
using namespace std;
const int MAX_N = 300;
int lc[MAX_N], cc[MAX_N];
int main() {
#ifdef HOME
FILE *fin = fopen("input.in", "r");
FILE *fout = fopen("output.ok", "w");
#else
FILE *fin = stdin;
FILE *fout = stdout;
#endif
int n, r, c, rez = 1000000000;
fscanf(fin, "%d%d", &r, &c);
fscanf(fin, "%d", &n);
for(int i = 0; i < n; ++i)
fscanf(fin, "%d%d", &lc[i], &cc[i]);
for(int down = 0; down <= r; ++down)
for(int up = 0; up <= r; ++up)
for(int left = 0; left <= c; ++left)
for(int right = 0; right <= c; ++right) {
bool okconf = true;
for(int lin = 1; lin <= r; ++lin)
for(int col = 1; col <= c; ++col) {
bool ok = false;
for(int i = 0; i < n; ++i)
if(lc[i] - left <= lin && lin <= lc[i] + right &&
cc[i] - up <= col && col <= cc[i] + down)
ok = true;
if(!ok)
okconf = false;
}
if(okconf)
rez = min(rez, left + up + down + right);
}
fprintf(fout, "%d", rez);
fclose(fin);
fclose(fout);
return 0;
}
Compilation message (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... |