답안 #95415

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
95415 2019-02-01T03:30:53 Z easrui JOI 문장 (JOI14_ho_t1) C++14
0 / 100
3 ms 376 KB
#include <bits/stdc++.h>
using namespace std;
const int MAX = 1e3+5;
int M,N,ans,res;
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]);
            ans += 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(ans,ans+res);
            }
    cout << ans;
}

Compilation message

2014_ho_t1.cpp: In function 'int main()':
2014_ho_t1.cpp:25:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)', declared with attribute warn_unused_result [-Wunused-result]
     freopen("input.txt","r",stdin);
     ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Incorrect 3 ms 376 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 3 ms 376 KB Output isn't correct
2 Halted 0 ms 0 KB -