Submission #95760

# Submission time Handle Problem Language Result Execution time Memory
95760 2019-02-02T12:40:03 Z easrui None (JOI14_ho_t1) C++14
0 / 100
2 ms 376 KB
#include <bits/stdc++.h>
using namespace std;
const int MAX = 1e3+5;
int M,N,ans,res,tmp;
char F[MAX][MAX],K[2][2],B[3]={'J','O','I'};
int C[MAX][MAX];

int match(int a, int b, int x, int y, char c)
{
    if(a<1 || a>=M || b<1 || b>=N)
        return 0;
    for(int i=0; i<2; i++)
        for(int j=0; j<2; j++) {
            if(a+i==x && b+j==y) {
                if(c!=K[i][j])
                    return 0;
            } else if(F[a+i][b+j]!=K[i][j])
                return 0;
        }
    return 1;
}

int main()
{
    //freopen("input.txt","r",stdin);
    ios_base::sync_with_stdio(0),cin.tie(0);
    cin >> M >> N;
    for(int i=1; i<=M; i++)
        for(int j=1; j<=N; j++)
            cin >> F[i][j];
    for(int i=0; i<2; i++)
        for(int j=0; j<2; j++)
            cin >> K[i][j];
    for(int i=0; i<=M; i++)
        for(int j=0; j<=N; j++) {
            C[i][j] = match(i,j,i,j,F[i][j]);
            tmp += C[i][j];
        }
    for(int i=1; i<=M; i++)
        for(int j=1; j<=N; j++)
            for(int k=0; k<3; k++) {
                res = 0;
                for(int x=-1; x<=0; x++)
                    for(int y=-1; y<=0; y++)
                        res += match(i+x,j+y,i,j,B[k]) - C[i+x][j+y];
                ans = max(tmp,tmp+res);
            }
    cout << ans;
}
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 376 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 376 KB Output isn't correct
2 Halted 0 ms 0 KB -