# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
151417 | TadijaSebez | JOI 문장 (JOI14_ho_t1) | C++11 | 162 ms | 3420 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>
using namespace std;
const int N=2005;
char flag[N][N],emblem[2][3];
int n,m;
int Check(int x, int y)
{
if(x<n && y<m && x>0 && y>0)
{
for(int i=0;i<2;i++)
for(int j=0;j<2;j++)
if(flag[x+i][y+j]!=emblem[i][j]) return 0;
return 1;
}
else return 0;
}
int Calc(int x, int y, char f)
{
char tmp=flag[x][y];
int pre=Check(x-1,y-1)+Check(x,y-1)+Check(x-1,y)+Check(x,y);
flag[x][y]=f;
int nxt=Check(x-1,y-1)+Check(x,y-1)+Check(x-1,y)+Check(x,y);
flag[x][y]=tmp;
return nxt-pre;
}
int main()
{
int ans=0,mx=0;
scanf("%i %i",&n,&m);
for(int i=1;i<=n;i++) scanf("%s",flag[i]+1);
scanf("%s %s",emblem[0],emblem[1]);
for(int i=1;i<=n;i++) for(int j=1;j<=m;j++)
{
mx=max(mx,Calc(i,j,'J'));
mx=max(mx,Calc(i,j,'O'));
mx=max(mx,Calc(i,j,'I'));
ans+=Check(i,j);
}
printf("%i\n",ans+mx);
return 0;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |