Submission #153812

#TimeUsernameProblemLanguageResultExecution timeMemory
153812songcJOI 문장 (JOI14_ho_t1)C++14
100 / 100
90 ms2424 KiB
#include <bits/stdc++.h> using namespace std; typedef long long LL; typedef pair<int,int> pii; int N, M, S, ans; char A[1010][1010]; char E[2][2]; int chk(int x, int y){ if (A[x][y] != E[0][0]) return 0; if (A[x][y+1] != E[0][1]) return 0; if (A[x+1][y] != E[1][0]) return 0; if (A[x+1][y+1] != E[1][1]) return 0; return 1; } int main(){ scanf("%d %d", &N, &M); for (int i=1; i<=N; i++) scanf("%s", A[i]+1); scanf("%s", E[0]); scanf("%s", E[1]); for (int i=1; i<=N-1; i++) for (int j=1; j<=M-1; j++) S += chk(i, j); ans = S; for (int i=1; i<=N; i++) for (int j=1; j<=M; j++){ int cnt = 0; char ch = A[i][j]; cnt -= chk(i-1, j-1); cnt -= chk(i-1, j); cnt -= chk(i, j-1); cnt -= chk(i, j); A[i][j] = 'J'; cnt += chk(i-1, j-1); cnt += chk(i-1, j); cnt += chk(i, j-1); cnt += chk(i, j); ans = max(ans, S+cnt); cnt -= chk(i-1, j-1); cnt -= chk(i-1, j); cnt -= chk(i, j-1); cnt -= chk(i, j); A[i][j] = 'O'; cnt += chk(i-1, j-1); cnt += chk(i-1, j); cnt += chk(i, j-1); cnt += chk(i, j); ans = max(ans, S+cnt); cnt -= chk(i-1, j-1); cnt -= chk(i-1, j); cnt -= chk(i, j-1); cnt -= chk(i, j); A[i][j] = 'I'; cnt += chk(i-1, j-1); cnt += chk(i-1, j); cnt += chk(i, j-1); cnt += chk(i, j); ans = max(ans, S+cnt); cnt -= chk(i-1, j-1); cnt -= chk(i-1, j); cnt -= chk(i, j-1); cnt -= chk(i, j); A[i][j] = ch; } printf("%d\n", ans); return 0; }

Compilation message (stderr)

2014_ho_t1.cpp: In function 'int main()':
2014_ho_t1.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);
  ~~~~~^~~~~~~~~~~~~~~~~
2014_ho_t1.cpp:20:32: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  for (int i=1; i<=N; i++) scanf("%s", A[i]+1);
                           ~~~~~^~~~~~~~~~~~~~
2014_ho_t1.cpp:21:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%s", E[0]);
  ~~~~~^~~~~~~~~~~~
2014_ho_t1.cpp:22:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%s", E[1]);
  ~~~~~^~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...