| # | Time | Username | Problem | Language | Result | Execution time | Memory |
|---|---|---|---|---|---|---|---|
| 145694 | TadijaSebez | Dango Maker (JOI18_dango_maker) | C++11 | 392 ms | 51612 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=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;
}
Compilation message (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... | ||||
