# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
958249 | MilosMilutinovic | JOI 문장 (JOI14_ho_t1) | C++14 | 18 ms | 14428 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 pb push_back
#define fi first
#define se second
#define mp make_pair
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef long double ld;
template <typename T> bool chkmin(T &x,T y){return x>y?x=y,1:0;}
template <typename T> bool chkmax(T &x,T y){return x<y?x=y,1:0;}
ll readint(){
ll x=0,f=1; char ch=getchar();
while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
return x*f;
}
int n,m;
char s[1005][1005],t[2][2];
int c[1005][1005][3];
int cod(char c){
if(c=='J') return 0;
if(c=='O') return 1;
if(c=='I') return 2;
}
int main(){
n=readint(); m=readint();
for(int i=1;i<=n;i++){
for(int j=1;j<=m;j++){
s[i][j]=getchar();
while(s[i][j]<'A'||s[i][j]>'Z') s[i][j]=getchar();
}
}
for(int i=0;i<2;i++) scanf("%s",t+i);
int ans=0;
for(int i=1;i<n;i++){
for(int j=1;j<m;j++){
int cnt=0;
for(int x=0;x<2;x++){
for(int y=0;y<2;y++){
if(s[i+x][j+y]!=t[x][y]) cnt++;
}
}
if(cnt>1) continue;
if(cnt==0){
ans++;
continue;
}
for(int x=0;x<2;x++){
for(int y=0;y<2;y++){
if(s[i+x][j+y]!=t[x][y]) c[i+x][j+y][cod(t[x][y])]++;
}
}
}
}
int mx=0;
for(int i=1;i<=n;i++){
for(int j=1;j<=m;j++){
for(int t=0;t<3;t++) chkmax(mx,c[i][j][t]);
}
}
printf("%d\n",ans+mx);
return 0;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |