답안 #153807

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
153807 2019-09-16T14:12:20 Z mhy908 JOI 문장 (JOI14_ho_t1) C++14
0 / 100
2 ms 504 KB
#include <bits/stdc++.h>
#define F first
#define S second
#define pb push_back
#define mp make_pair
#define llinf 8987654321987654321
#define inf 1987654321
using namespace std;
typedef long long LL;
typedef pair<int, int> pii;
typedef pair<LL, LL> pll;
int n, m;
char str[3010][3010];
char arr[10][10];
bool poss[3010][3010];
int ans, num;
char c[10]=" JOI";
int main()
{
    scanf("%d %d", &n, &m);
    for(int i=1; i<=n; i++)scanf("%s", str[i]+1);
    scanf("%s", arr[0]);
    scanf("%s", arr[1]);
    for(int i=1; i<n; i++){
        for(int j=1; j<m; j++){
            poss[i][j]=true;
            for(int k=0; k<=1; k++)
                for(int l=0; l<=1; l++)
                    if(str[i+k][j+l]!=arr[k][l])poss[i][j]=false;
            if(poss[i][j])num++;
        }
    }
    ans=num;
    for(int i=1; i<=n; i++){
        for(int j=1; j<=m; j++){
            int temp=num;
            for(int k=i; k>=i-1&&k>=1; k--)
                for(int l=j; l>=j-1&&l>=1; l--)
                    if(poss[k][l])temp--;
            for(int z=1; z<=3; z++){
                char t=str[i][j];
                int tempp=temp;
                str[i][j]=c[z];
                for(int k=i; k>=i-1&&k>=1; k--)
                    for(int l=j; l>=j-1&&l>=1; l--){
                        bool flag=true;
                        for(int a=0; a<=1; a++)
                            for(int b=0; b<=1; b++)
                                if(str[k+a][l+b]!=arr[a][b])flag=false;
                        if(flag)tempp++;
                    }
                ans=max(ans, tempp);
            }
        }
    }
    printf("%d", ans);
}

Compilation message

2014_ho_t1.cpp: In function 'int main()':
2014_ho_t1.cpp:41:22: warning: unused variable 't' [-Wunused-variable]
                 char t=str[i][j];
                      ^
2014_ho_t1.cpp:20:10: 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:21:33: 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", str[i]+1);
                            ~~~~~^~~~~~~~~~~~~~~~
2014_ho_t1.cpp:22:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%s", arr[0]);
     ~~~~~^~~~~~~~~~~~~~
2014_ho_t1.cpp:23:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%s", arr[1]);
     ~~~~~^~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 504 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 504 KB Output isn't correct
2 Halted 0 ms 0 KB -