# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
74347 | khsoo01 | Oriental P.A.D.A.K (FXCUP2_padak) | C++11 | 367 ms | 65828 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 inf = 1e9;
int n, m, k, b, z, x, y, a[1000005], d[1000005];
queue<int> q;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
int main()
{
scanf("%d%d%d%d%d",&n,&m,&k,&b,&z);
for(int i=0;i<n*m;i++) d[i] = inf;
for(int i=1;i<=k;i++) {
int A, B;
scanf("%d%d",&A,&B); A--; B--;
if(d[A*m+B] == inf) {
d[A*m+B] = 0;
q.push(A*m+B);
}
}
while(!q.empty()) {
int T = q.front(); q.pop();
int A = T/m, B = T%m;
if(y/z < d[T]) y++;
a[d[T]]++;
for(int i=0;i<4;i++) {
int na = A+dx[i], nb = B+dy[i];
if(0 <= na && na < n && 0 <= nb && nb < m && d[na*m+nb] == inf) {
d[na*m+nb] = d[T] + 1;
q.push(na*m+nb);
}
}
}
for(int i=n*m;i>=0;i--) {
for(int j=0;j<a[i];j++) {
if(x/z < i) x++;
}
}
printf("%d %d\n",x,y);
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |