/* Author : Mychecksdead */
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define MOD (1000000000+7)
#define MOD1 (998244353)
#define pb push_back
#define all(x) x.begin(), x.end()
#define en cout << '\n'
#define ff first
#define ss second
#define pii pair<int,int>
#define vi vector<int>
const int N = 1e6+100, M = 1e5+10, K = 52, MX = 30;
int n, m, w;
array<int, 2> a[N];
void solve(){
cin >> n >> m >> w;
for(int i = 1; i <= w; ++i){
cin >> a[i][0] >> a[i][1];
--a[i][0];
--a[i][1];
}
int ans = INT_MAX;
for(int u = 0; u <= n; ++u){
for(int d = 0; d <= n; ++d){
for(int l = 0; l <= m; ++l){
for(int r = 0; r <= m; ++r){
vector<vector<bool>> is(n, vector<bool>(m));
for(int i = 1; i <= w; ++i){
for(int x = max(0, a[i][0] - u); x <= min(n-1, a[i][0] + d); ++x){
for(int y = max(0, a[i][1] - l); y <= min(m-1, a[i][1] + r); ++y){
is[x][y] = 1;
}
}
}
bool ok = 1;
for(auto &u: is){
for(bool f: u){
if(!f){
ok = false;
}
}
}
if(ok) ans = min(ans, u+d+l+r);
}
}
}
}
cout << ans;
}
int main(){
cin.tie(0); ios::sync_with_stdio(0);
int tt = 1, aa;
// freopen("in.txt", "r", stdin);
// freopen("out.txt", "w", stdout);
while(tt--){
solve();
en;
}
cerr<<"time taken : "<<(float)clock()/CLOCKS_PER_SEC<<" seconds\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... |