#include <bits/stdc++.h>
using namespace std;
#define LCBorz ios_base::sync_with_stdio(false); cin.tie(0);
#define all(x) x.begin(), x.end()
#define endl '\n'
const int N=200005;
const int INF=1e9;
int32_t main() {
LCBorz;
int r,c;cin>>r>>c;
int n;cin>>n;
vector dis(r+2,vector(c+2,INF));
vector<int> a(n),b(n);
for(int i=0;i<n;i++){
cin>>a[i]>>b[i];
dis[a[i]][b[i]]=0;
}
vector<int> dx={1,-1,0,0},dy={0,0,1,-1};
queue<pair<int,int>> q;
auto check=[&](int a,int b){
return (a>0&&a<=r&&b>0&&b<r&&dis[a][b]==INF);
};
int ans=0;
for(int k=0;k<4;k++){
for(int i=1;i<=r;i++){
for(int j=1;j<=c;j++){
if(dis[i][j]!=INF){
dis[i][j]=0;
q.push({i,j});
}
}
}
int mx=0;
while(q.size()){
auto [a,b]=q.front();
q.pop();
mx=max(mx,dis[a][b]);
int c=a+dx[k];
int d=b+dy[k];
if(check(c,d)){
dis[c][d]=dis[a][b]+1;
q.push({c,d});
}
}
ans+=mx;
}
cout<<ans<<endl;
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
344 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
344 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
344 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
59 ms |
262144 KB |
Execution killed with signal 9 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
59 ms |
262144 KB |
Execution killed with signal 9 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
344 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |