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;
typedef long long ll;
int n, m, cnt;
struct point {
int x;
int y;
};
bool operator < (point a, point b) {
if (a.x != b.x) return a.x < b.x;
return a.y < b.y;
}
bool valid(point a) {
return 1 <= a.x && a.x <= n && 1 <= a.y && a.y <= m;
}
const int N = 300 + 7;
point pt[N];
int sol = (int) 2e9 + 7;
signed main() {
ios::sync_with_stdio(0); cin.tie(0);
///freopen ("input", "r", stdin);
cin >> n >> m >> cnt;
for (int i = 1; i <= cnt; i++) {
cin >> pt[i].x >> pt[i].y;
}
for (int a = 0; a <= n; a++) {
for (int b = 0; b <= n; b++) {
for (int c = 0; c <= m; c++) {
for (int d = 0; d <= m; d++) {
set<point> s;
for (int i = 1; i <= cnt; i++) {
for (int ff = pt[i].x - a; ff <= pt[i].x + b; ff++) {
for (int ss = pt[i].y - c; ss <= pt[i].y + d; ss++) {
if (valid({ff, ss})) {
s.insert({ff, ss});
}
}
}
}
if ((int) s.size() == n * m) {
sol = min(sol, a + b + c + d);
}
}
}
}
}
cout << sol << "\n";
return 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... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |