Submission #247086

#TimeUsernameProblemLanguageResultExecution timeMemory
247086arnold518Sandwich (JOI16_sandwich)C++14
0 / 100
5 ms384 KiB
#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)

sandwich.cpp: In function 'int main()':
sandwich.cpp:19:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d%d", &N, &M);
  ~~~~~^~~~~~~~~~~~~~~~
sandwich.cpp:20:27: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  for(i=1; i<=N; i++) scanf(" %s", A[i]+1);
                      ~~~~~^~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...