# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
153809 | mhy908 | JOI 문장 (JOI14_ho_t1) | C++14 | 138 ms | 7288 KiB |
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 <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);
str[i][j]=t;
}
}
}
printf("%d", ans);
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |