Submission #761578

#TimeUsernameProblemLanguageResultExecution timeMemory
761578hgmhcJOI 문장 (JOI14_ho_t1)C++17
100 / 100
49 ms1284 KiB
#include <bits/stdc++.h> #define rep(i,a,b) for (auto i = (a); i <= (b); ++i) #define Mup(x,y) x = max(x,y) #define mup(x,y) x = min(x,y) #define all(x) begin(x),end(x) #define per(i,a,b) for (auto i = (b); i >= (a); --i) using namespace std; const int N = 1003, M = 1003; int n, m; char f[N][M], s[3][3]; bool valid(int x, int y) { rep(i,0,1) rep(j,0,1) if (f[x+i][y+j] != s[i][j]) return false; return true; } int main() { scanf("%d%d", &n, &m); rep(i,1,n) scanf(" %s ", f[i]+1); scanf("%c%c %c%c", &s[0][0],&s[0][1],&s[1][0],&s[1][1]); int diff = 0; rep(i,1,n) rep(j,1,m) { int minus = 0, plus = 0; char tmp = f[i][j]; rep(x,0,1) rep(y,0,1) minus += valid(i-x,j-y); for (char c : {'J','O','I'}) { f[i][j] = c; int p = 0; rep(x,0,1) rep(y,0,1) p += valid(i-x,j-y); Mup(plus, p); } Mup(diff, plus-minus); f[i][j] = tmp; } int val = 0; rep(i,1,n-1) rep(j,1,m-1) { val += valid(i,j); } // printf("%d+(%d)", val,diff); printf("%d", val+diff); }

Compilation message (stderr)

2014_ho_t1.cpp: In function 'int main()':
2014_ho_t1.cpp:19:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   19 |     scanf("%d%d", &n, &m);
      |     ~~~~~^~~~~~~~~~~~~~~~
2014_ho_t1.cpp:20:21: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   20 |     rep(i,1,n) scanf(" %s ", f[i]+1);
      |                ~~~~~^~~~~~~~~~~~~~~~
2014_ho_t1.cpp:21:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   21 |     scanf("%c%c %c%c", &s[0][0],&s[0][1],&s[1][0],&s[1][1]);
      |     ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...