# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
247086 | arnold518 | Sandwich (JOI16_sandwich) | C++14 | 5 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;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int MAXN = 400;
const int INF = 1e7;
int N, M;
char A[MAXN+10][MAXN+10];
int ans[MAXN+10][MAXN+10];
int main()
{
int i, j, k;
scanf("%d%d", &N, &M);
for(i=1; i<=N; i++) scanf(" %s", A[i]+1);
for(i=1; i<=N; i++) for(j=1; j<=M; j++) ans[i][j]=INF;
for(k=1; k<=N*M; k++)
{
for(i=1; i<=N; i++) for(j=1; j<=M; j++)
{
if(A[i][j]=='N')
{
ans[i][j]=min(ans[i][j], max(ans[i-1][j], ans[i][j+1])+1);
ans[i][j]=min(ans[i][j], max(ans[i+1][j], ans[i][j-1])+1);
}
else
{
ans[i][j]=min(ans[i][j], max(ans[i-1][j], ans[i][j-1])+1);
ans[i][j]=min(ans[i][j], max(ans[i+1][j], ans[i][j+1])+1);
}
}
}
for(i=1; i<=N; i++)
{
for(j=1; j<=M; j++)
{
if(ans[i][j]==INF) printf("-1 ");
else printf("%d ", ans[i][j]*2);
}
printf("\n");
}
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |