# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
153801 | mhy908 | Dango Maker (JOI18_dango_maker) | C++14 | 2 ms | 376 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 F first
#define S second
#define pb push_back
#define mp make_pair
#define llinf 8987654321987654321
#define inf 1987654321
using namespace std;
typedef long long LL;
typedef pair<int, int> pii;
typedef pair<LL, LL> pll;
int n, m;
char str[3010][3010];
int dp[6010], arr[6010], ans;
int main()
{
scanf("%d %d", &n, &m);
for(int i=1; i<=n; i++)scanf("%s", str[i]+1);
for(int i=2; i<=n+m; i++){
memset(dp, 0, sizeof(dp));
memset(arr, 0, sizeof(arr));
for(int j=1; j<i; j++){
dp[j]=dp[j-1];
int x=i-j, y=j;
if(x>n||y>m)continue;
if(str[x][y]=='G'&&str[x-1][y]=='R'&&str[x+1][y]=='W')arr[j]+=1;
if(str[x][y]=='G'&&str[x][y-1]=='R'&&str[x][y+1]=='W')arr[j]+=2;
if(!arr[j-1]&&arr[j])dp[j]++;
else if(arr[j]==3)dp[j]++;
else if(arr[j]==1&&(arr[j-1]&1))dp[j]++;
else if(arr[j]==2&&(arr[j-1]&2))dp[j]++;
if(arr[j]==3&&arr[j-1]==1)arr[j]=1;
if(arr[j]==3&&arr[j-1]==2)arr[j]=2;
}
ans+=dp[i-1];
}
printf("%d", ans);
}
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... |