# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
145694 | TadijaSebez | Dango Maker (JOI18_dango_maker) | C++11 | 392 ms | 51612 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
const int N=3005;
const int M=2*N;
const int inf=1e9+7;
bool can[M][N][2];
char s[N][N];
int dp[N][2][2];
void Clear(){ for(int i=0;i<N;i++) dp[i][0][0]=dp[i][1][0]=dp[i][0][1]=dp[i][1][1]=-inf;}
void ckmx(int &a, int b){ a=max(a,b);}
int main()
{
int n,m;
scanf("%i %i",&n,&m);
for(int i=1;i<=n;i++) scanf("%s",s[i]+1);
for(int i=1;i<=n;i++) for(int j=1;j<=m;j++)
{
if(s[i][j]=='R' && s[i][j+1]=='G' && s[i][j+2]=='W') can[i+j][i][0]=1;
if(s[i][j]=='R' && s[i+1][j]=='G' && s[i+2][j]=='W') can[i+j][i][1]=1;
}
int ans=0;
for(int z=2;z<=n+m;z++)
{
Clear();
dp[0][0][0]=0;
for(int i=1;i<=n;i++)
{
for(int x=0;x<2;x++) for(int y=0;y<2;y++)
{
ckmx(dp[i][0][x],dp[i-1][x][y]);
if(can[z][i][0] && x==0 && y==0) ckmx(dp[i][0][x],dp[i-1][x][y]+1);
if(can[z][i][1]) ckmx(dp[i][1][x],dp[i-1][x][y]+1);
}
}
int tmp=0;
for(int x=0;x<2;x++) for(int y=0;y<2;y++) ckmx(tmp,dp[n][x][y]);
ans+=tmp;
}
printf("%i\n",ans);
return 0;
}
컴파일 시 표준 에러 (stderr) 메시지
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |