답안 #860245

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
860245 2023-10-12T09:42:49 Z StefanSebez Dango Maker (JOI18_dango_maker) C++14
100 / 100
353 ms 80676 KB
#include <bits/stdc++.h>
using namespace std;
#define int long long
signed main()
{
    int n,m;cin>>n>>m;
    int a[n+10][m+10];
    memset(a,-1,sizeof(a));
    for(int i=1;i<=n;i++)
	{
		string s;cin>>s;
		for(int j=0;j<m;j++)
		{
			if(s[j]=='R') a[i][j+1]=0;
			if(s[j]=='G') a[i][j+1]=1;
			if(s[j]=='W') a[i][j+1]=2;
		}
	}
	int res=0;
	for(int d=1;d<=n+m;d++)
	{
		int i=1,j=d-1,ct=1,dp[n+m+10][5];
		memset(dp,0,sizeof(dp));
		while(i<=n && j>=1)
		{
			if(j>m)
			{
				i++;
				j--;
				continue;
			}
			dp[ct][0]=max(dp[ct-1][0],max(dp[ct-1][1],dp[ct-1][2]));
			if(a[i][j-1]==0 && a[i][j]==1 && a[i][j+1]==2) dp[ct][1]=max(dp[ct-1][0],dp[ct-1][1])+1;
			if(a[i-1][j]==0 && a[i][j]==1 && a[i+1][j]==2) dp[ct][2]=max(dp[ct-1][0],dp[ct-1][2])+1;
			i++;
			j--;
			ct++;
		}
		ct--;
		res+=max(dp[ct][0],max(dp[ct][1],dp[ct][2]));
	}
	cout<<res<<endl;
    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 356 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 352 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 0 ms 352 KB Output is correct
15 Correct 0 ms 440 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 356 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 352 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 0 ms 352 KB Output is correct
15 Correct 0 ms 440 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
17 Correct 0 ms 348 KB Output is correct
18 Correct 0 ms 348 KB Output is correct
19 Correct 0 ms 348 KB Output is correct
20 Correct 0 ms 348 KB Output is correct
21 Correct 0 ms 348 KB Output is correct
22 Correct 0 ms 348 KB Output is correct
23 Correct 0 ms 348 KB Output is correct
24 Correct 0 ms 352 KB Output is correct
25 Correct 0 ms 352 KB Output is correct
26 Correct 0 ms 352 KB Output is correct
27 Correct 0 ms 352 KB Output is correct
28 Correct 1 ms 352 KB Output is correct
29 Correct 0 ms 352 KB Output is correct
30 Correct 0 ms 352 KB Output is correct
31 Correct 0 ms 604 KB Output is correct
32 Correct 0 ms 352 KB Output is correct
33 Correct 0 ms 352 KB Output is correct
34 Correct 0 ms 352 KB Output is correct
35 Correct 0 ms 352 KB Output is correct
36 Correct 1 ms 352 KB Output is correct
37 Correct 0 ms 352 KB Output is correct
38 Correct 0 ms 352 KB Output is correct
39 Correct 0 ms 352 KB Output is correct
40 Correct 0 ms 352 KB Output is correct
41 Correct 0 ms 352 KB Output is correct
42 Correct 0 ms 352 KB Output is correct
43 Correct 0 ms 440 KB Output is correct
44 Correct 0 ms 352 KB Output is correct
45 Correct 0 ms 352 KB Output is correct
46 Correct 0 ms 352 KB Output is correct
47 Correct 0 ms 352 KB Output is correct
48 Correct 0 ms 352 KB Output is correct
49 Correct 0 ms 352 KB Output is correct
50 Correct 1 ms 592 KB Output is correct
51 Correct 1 ms 352 KB Output is correct
52 Correct 0 ms 352 KB Output is correct
53 Correct 0 ms 352 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 356 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 352 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 0 ms 352 KB Output is correct
15 Correct 0 ms 440 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
17 Correct 0 ms 348 KB Output is correct
18 Correct 0 ms 348 KB Output is correct
19 Correct 0 ms 348 KB Output is correct
20 Correct 0 ms 348 KB Output is correct
21 Correct 0 ms 348 KB Output is correct
22 Correct 0 ms 348 KB Output is correct
23 Correct 0 ms 348 KB Output is correct
24 Correct 0 ms 352 KB Output is correct
25 Correct 0 ms 352 KB Output is correct
26 Correct 0 ms 352 KB Output is correct
27 Correct 0 ms 352 KB Output is correct
28 Correct 1 ms 352 KB Output is correct
29 Correct 0 ms 352 KB Output is correct
30 Correct 0 ms 352 KB Output is correct
31 Correct 0 ms 604 KB Output is correct
32 Correct 0 ms 352 KB Output is correct
33 Correct 0 ms 352 KB Output is correct
34 Correct 0 ms 352 KB Output is correct
35 Correct 0 ms 352 KB Output is correct
36 Correct 1 ms 352 KB Output is correct
37 Correct 0 ms 352 KB Output is correct
38 Correct 0 ms 352 KB Output is correct
39 Correct 0 ms 352 KB Output is correct
40 Correct 0 ms 352 KB Output is correct
41 Correct 0 ms 352 KB Output is correct
42 Correct 0 ms 352 KB Output is correct
43 Correct 0 ms 440 KB Output is correct
44 Correct 0 ms 352 KB Output is correct
45 Correct 0 ms 352 KB Output is correct
46 Correct 0 ms 352 KB Output is correct
47 Correct 0 ms 352 KB Output is correct
48 Correct 0 ms 352 KB Output is correct
49 Correct 0 ms 352 KB Output is correct
50 Correct 1 ms 592 KB Output is correct
51 Correct 1 ms 352 KB Output is correct
52 Correct 0 ms 352 KB Output is correct
53 Correct 0 ms 352 KB Output is correct
54 Correct 6 ms 608 KB Output is correct
55 Correct 8 ms 604 KB Output is correct
56 Correct 6 ms 860 KB Output is correct
57 Correct 4 ms 600 KB Output is correct
58 Correct 35 ms 9392 KB Output is correct
59 Correct 353 ms 80208 KB Output is correct
60 Correct 345 ms 80212 KB Output is correct
61 Correct 353 ms 80464 KB Output is correct
62 Correct 5 ms 604 KB Output is correct
63 Correct 330 ms 77664 KB Output is correct
64 Correct 291 ms 80464 KB Output is correct
65 Correct 273 ms 80380 KB Output is correct
66 Correct 273 ms 80212 KB Output is correct
67 Correct 336 ms 80396 KB Output is correct
68 Correct 276 ms 80208 KB Output is correct
69 Correct 275 ms 80676 KB Output is correct
70 Correct 24 ms 9308 KB Output is correct
71 Correct 24 ms 9308 KB Output is correct
72 Correct 26 ms 9308 KB Output is correct
73 Correct 24 ms 9300 KB Output is correct
74 Correct 25 ms 9304 KB Output is correct
75 Correct 24 ms 9304 KB Output is correct
76 Correct 27 ms 9388 KB Output is correct
77 Correct 27 ms 9472 KB Output is correct
78 Correct 24 ms 9308 KB Output is correct
79 Correct 24 ms 9304 KB Output is correct
80 Correct 24 ms 9308 KB Output is correct
81 Correct 24 ms 9392 KB Output is correct
82 Correct 25 ms 9396 KB Output is correct
83 Correct 26 ms 9476 KB Output is correct
84 Correct 25 ms 9308 KB Output is correct
85 Correct 26 ms 9388 KB Output is correct
86 Correct 24 ms 9308 KB Output is correct
87 Correct 25 ms 9308 KB Output is correct
88 Correct 26 ms 9476 KB Output is correct
89 Correct 26 ms 9304 KB Output is correct
90 Correct 25 ms 9284 KB Output is correct