이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int MAXN = 1000;
int N, M, ans;
char S[MAXN+10][MAXN+10], T[3][3];
int chk(int y, int x)
{
int i, j;
for(i=0; i<2; i++) for(j=0; j<2; j++) if(S[y+i][x+j]!=T[i][j]) return 0;
return 1;
}
int main()
{
int i, j;
scanf("%d%d", &N, &M);
for(i=1; i<=N; i++) scanf("%s", S[i]+1);
for(i=0; i<2; i++) scanf("%s", T[i]);
int cnt=0;
for(i=1; i<=N; i++) for(j=1; j<=M; j++) cnt+=chk(i, j);
ans=cnt;
for(i=1; i<=N; i++) for(j=1; j<=M; j++)
{
char t=S[i][j];
cnt-=chk(i-1, j-1)+chk(i-1, j)+chk(i, j-1)+chk(i, j);
S[i][j]='J';
cnt+=chk(i-1, j-1)+chk(i-1, j)+chk(i, j-1)+chk(i, j);
ans=max(ans, cnt);
cnt-=chk(i-1, j-1)+chk(i-1, j)+chk(i, j-1)+chk(i, j);
S[i][j]='O';
cnt+=chk(i-1, j-1)+chk(i-1, j)+chk(i, j-1)+chk(i, j);
ans=max(ans, cnt);
cnt-=chk(i-1, j-1)+chk(i-1, j)+chk(i, j-1)+chk(i, j);
S[i][j]='I';
cnt+=chk(i-1, j-1)+chk(i-1, j)+chk(i, j-1)+chk(i, j);
ans=max(ans, cnt);
cnt-=chk(i-1, j-1)+chk(i-1, j)+chk(i, j-1)+chk(i, j);
S[i][j]=t;
cnt+=chk(i-1, j-1)+chk(i-1, j)+chk(i, j-1)+chk(i, j);
}
printf("%d", ans);
}
컴파일 시 표준 에러 (stderr) 메시지
2014_ho_t1.cpp: In function 'int main()':
2014_ho_t1.cpp:24: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:25:30: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
for(i=1; i<=N; i++) scanf("%s", S[i]+1);
~~~~~^~~~~~~~~~~~~~
2014_ho_t1.cpp:26:29: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
for(i=0; i<2; i++) scanf("%s", T[i]);
~~~~~^~~~~~~~~~~~
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |