# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
247086 | 2020-07-11T04:55:32 Z | arnold518 | Sandwich (JOI16_sandwich) | C++14 | 5 ms | 384 KB |
#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
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 4 ms | 256 KB | Output is correct |
2 | Correct | 5 ms | 384 KB | Output is correct |
3 | Correct | 5 ms | 384 KB | Output is correct |
4 | Correct | 5 ms | 384 KB | Output is correct |
5 | Incorrect | 5 ms | 384 KB | Output isn't correct |
6 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 4 ms | 256 KB | Output is correct |
2 | Correct | 5 ms | 384 KB | Output is correct |
3 | Correct | 5 ms | 384 KB | Output is correct |
4 | Correct | 5 ms | 384 KB | Output is correct |
5 | Incorrect | 5 ms | 384 KB | Output isn't correct |
6 | Halted | 0 ms | 0 KB | - |