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 <stdio.h>
#define N 1000
#define M 1000
int max(int a, int b) { return a > b ? a : b; }
int count(char cc[][M + 1], char aa[][3], int n, int m) {
int i, j, i_, j_, cnt;
cnt = 0;
for (i = 0; i + 1 < n; i++)
for (j = 0; j + 1 < m; j++) {
int match;
match = 1;
for (i_ = 0; i_ < 2; i_++)
for (j_ = 0; j_ < 2; j_++)
if (cc[i + i_][j + j_] != aa[i_][j_]) {
match = 0;
break;
}
if (match)
cnt++;
}
return cnt;
}
int main() {
static char cc[N][M + 1], aa[2][3];
int n, m, i, j, ans;
scanf("%d%d", &n, &m);
for (i = 0; i < n; i++)
scanf("%s", cc[i]);
for (i = 0; i < 2; i++)
scanf("%s", aa[i]);
ans = 0;
for (i = 0; i < n; i++)
for (j = 0; j < m; j++) {
char c = cc[i][j];
cc[i][j] = 'J';
ans = max(ans, count(cc, aa, n, m));
cc[i][j] = 'O';
ans = max(ans, count(cc, aa, n, m));
cc[i][j] = 'I';
ans = max(ans, count(cc, aa, n, m));
cc[i][j] = c;
}
printf("%d\n", ans);
return 0;
}
Compilation message (stderr)
2014_ho_t1.c: In function 'main':
2014_ho_t1.c:33:2: warning: ignoring return value of 'scanf' declared with attribute 'warn_unused_result' [-Wunused-result]
33 | scanf("%d%d", &n, &m);
| ^~~~~~~~~~~~~~~~~~~~~
2014_ho_t1.c:35:3: warning: ignoring return value of 'scanf' declared with attribute 'warn_unused_result' [-Wunused-result]
35 | scanf("%s", cc[i]);
| ^~~~~~~~~~~~~~~~~~
2014_ho_t1.c:37:3: warning: ignoring return value of 'scanf' declared with attribute 'warn_unused_result' [-Wunused-result]
37 | scanf("%s", aa[i]);
| ^~~~~~~~~~~~~~~~~~
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |