답안 #708823

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
708823 2023-03-12T11:55:33 Z myrcella Dango Maker (JOI18_dango_maker) C++17
100 / 100
206 ms 115404 KB
//by szh
#include<bits/stdc++.h>
using namespace std;

#define fi first
#define se second
#define pii pair<int,int>
#define pll pair<long long,long long>
#define pb push_back
#define debug(x) cerr<<#x<<"="<<x<<endl
#define pq priority_queue
#define inf 0x3f
#define rep(i,a,b) for (int i=a;i<(b);i++)
#define MP make_pair
#define SZ(x) (int(x.size()))
#define ll long long
#define mod 1000000007
#define ALL(x) x.begin(),x.end()
void inc(int &a,int b) {a=(a+b)%mod;}
void dec(int &a,int b) {a=(a-b+mod)%mod;}
int lowbit(int x) {return x&(-x);}
ll p0w(ll base,ll p) {ll ret=1;while(p>0){if (p%2ll==1ll) ret=ret*base%mod;base=base*base%mod;p/=2ll;}return ret;}

const int maxn = 3010;

int n,m;
int grid[maxn][maxn];
int dp[maxn][maxn][2];

int main() {
//	freopen("input.txt","r",stdin);	
	std::ios::sync_with_stdio(false);cin.tie(0);
	cin>>n>>m;
	memset(grid,-1,sizeof(grid));
	rep(i,1,n+1) {
		string s;cin>>s;
		rep(j,1,m+1) {
			if (s[j-1]=='R') grid[i][j]=0;
			else if (s[j-1]=='G') grid[i][j]=1;
			else grid[i][j]=2;
		}
	}
	int ans = 0;
	rep(i,1,n+1)
		rep(j,1,m+1) {
			if (grid[i][j]==1) {
				dp[i][j][0] = dp[i][j][1] = max(dp[i-1][j+1][1],dp[i-1][j+1][0]);
				if (grid[i-1][j]==0 and grid[i+1][j]==2) dp[i][j][1] = max(dp[i][j][1],dp[i-1][j+1][1] + 1);
				if (grid[i][j-1]==0 and grid[i][j+1]==2) dp[i][j][0] = max(dp[i][j][0],dp[i-1][j+1][0] + 1);
				if (grid[i+1][j-1]!=1) ans += max(dp[i][j][0],dp[i][j][1]);
			}
		}
	cout<<ans;
	return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 16 ms 35668 KB Output is correct
2 Correct 16 ms 35668 KB Output is correct
3 Correct 16 ms 35684 KB Output is correct
4 Correct 15 ms 35780 KB Output is correct
5 Correct 15 ms 35668 KB Output is correct
6 Correct 19 ms 35716 KB Output is correct
7 Correct 16 ms 35740 KB Output is correct
8 Correct 16 ms 35796 KB Output is correct
9 Correct 17 ms 35676 KB Output is correct
10 Correct 15 ms 35676 KB Output is correct
11 Correct 16 ms 35796 KB Output is correct
12 Correct 17 ms 35812 KB Output is correct
13 Correct 17 ms 35768 KB Output is correct
14 Correct 15 ms 35668 KB Output is correct
15 Correct 18 ms 35916 KB Output is correct
16 Correct 18 ms 35780 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 16 ms 35668 KB Output is correct
2 Correct 16 ms 35668 KB Output is correct
3 Correct 16 ms 35684 KB Output is correct
4 Correct 15 ms 35780 KB Output is correct
5 Correct 15 ms 35668 KB Output is correct
6 Correct 19 ms 35716 KB Output is correct
7 Correct 16 ms 35740 KB Output is correct
8 Correct 16 ms 35796 KB Output is correct
9 Correct 17 ms 35676 KB Output is correct
10 Correct 15 ms 35676 KB Output is correct
11 Correct 16 ms 35796 KB Output is correct
12 Correct 17 ms 35812 KB Output is correct
13 Correct 17 ms 35768 KB Output is correct
14 Correct 15 ms 35668 KB Output is correct
15 Correct 18 ms 35916 KB Output is correct
16 Correct 18 ms 35780 KB Output is correct
17 Correct 17 ms 35784 KB Output is correct
18 Correct 19 ms 35724 KB Output is correct
19 Correct 15 ms 35788 KB Output is correct
20 Correct 16 ms 35796 KB Output is correct
21 Correct 19 ms 35868 KB Output is correct
22 Correct 16 ms 35796 KB Output is correct
23 Correct 16 ms 35780 KB Output is correct
24 Correct 18 ms 35796 KB Output is correct
25 Correct 16 ms 35796 KB Output is correct
26 Correct 16 ms 35668 KB Output is correct
27 Correct 17 ms 35784 KB Output is correct
28 Correct 16 ms 35832 KB Output is correct
29 Correct 17 ms 35796 KB Output is correct
30 Correct 15 ms 35756 KB Output is correct
31 Correct 16 ms 35796 KB Output is correct
32 Correct 16 ms 35756 KB Output is correct
33 Correct 18 ms 35788 KB Output is correct
34 Correct 16 ms 35800 KB Output is correct
35 Correct 16 ms 35772 KB Output is correct
36 Correct 16 ms 35740 KB Output is correct
37 Correct 16 ms 35804 KB Output is correct
38 Correct 19 ms 35796 KB Output is correct
39 Correct 19 ms 35712 KB Output is correct
40 Correct 20 ms 35712 KB Output is correct
41 Correct 20 ms 35800 KB Output is correct
42 Correct 18 ms 35796 KB Output is correct
43 Correct 14 ms 35796 KB Output is correct
44 Correct 15 ms 35792 KB Output is correct
45 Correct 16 ms 35812 KB Output is correct
46 Correct 19 ms 35768 KB Output is correct
47 Correct 15 ms 35772 KB Output is correct
48 Correct 17 ms 35776 KB Output is correct
49 Correct 16 ms 35888 KB Output is correct
50 Correct 17 ms 35768 KB Output is correct
51 Correct 16 ms 35796 KB Output is correct
52 Correct 15 ms 35804 KB Output is correct
53 Correct 15 ms 35796 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 16 ms 35668 KB Output is correct
2 Correct 16 ms 35668 KB Output is correct
3 Correct 16 ms 35684 KB Output is correct
4 Correct 15 ms 35780 KB Output is correct
5 Correct 15 ms 35668 KB Output is correct
6 Correct 19 ms 35716 KB Output is correct
7 Correct 16 ms 35740 KB Output is correct
8 Correct 16 ms 35796 KB Output is correct
9 Correct 17 ms 35676 KB Output is correct
10 Correct 15 ms 35676 KB Output is correct
11 Correct 16 ms 35796 KB Output is correct
12 Correct 17 ms 35812 KB Output is correct
13 Correct 17 ms 35768 KB Output is correct
14 Correct 15 ms 35668 KB Output is correct
15 Correct 18 ms 35916 KB Output is correct
16 Correct 18 ms 35780 KB Output is correct
17 Correct 17 ms 35784 KB Output is correct
18 Correct 19 ms 35724 KB Output is correct
19 Correct 15 ms 35788 KB Output is correct
20 Correct 16 ms 35796 KB Output is correct
21 Correct 19 ms 35868 KB Output is correct
22 Correct 16 ms 35796 KB Output is correct
23 Correct 16 ms 35780 KB Output is correct
24 Correct 18 ms 35796 KB Output is correct
25 Correct 16 ms 35796 KB Output is correct
26 Correct 16 ms 35668 KB Output is correct
27 Correct 17 ms 35784 KB Output is correct
28 Correct 16 ms 35832 KB Output is correct
29 Correct 17 ms 35796 KB Output is correct
30 Correct 15 ms 35756 KB Output is correct
31 Correct 16 ms 35796 KB Output is correct
32 Correct 16 ms 35756 KB Output is correct
33 Correct 18 ms 35788 KB Output is correct
34 Correct 16 ms 35800 KB Output is correct
35 Correct 16 ms 35772 KB Output is correct
36 Correct 16 ms 35740 KB Output is correct
37 Correct 16 ms 35804 KB Output is correct
38 Correct 19 ms 35796 KB Output is correct
39 Correct 19 ms 35712 KB Output is correct
40 Correct 20 ms 35712 KB Output is correct
41 Correct 20 ms 35800 KB Output is correct
42 Correct 18 ms 35796 KB Output is correct
43 Correct 14 ms 35796 KB Output is correct
44 Correct 15 ms 35792 KB Output is correct
45 Correct 16 ms 35812 KB Output is correct
46 Correct 19 ms 35768 KB Output is correct
47 Correct 15 ms 35772 KB Output is correct
48 Correct 17 ms 35776 KB Output is correct
49 Correct 16 ms 35888 KB Output is correct
50 Correct 17 ms 35768 KB Output is correct
51 Correct 16 ms 35796 KB Output is correct
52 Correct 15 ms 35804 KB Output is correct
53 Correct 15 ms 35796 KB Output is correct
54 Correct 15 ms 35784 KB Output is correct
55 Correct 18 ms 39928 KB Output is correct
56 Correct 15 ms 35924 KB Output is correct
57 Correct 20 ms 43732 KB Output is correct
58 Correct 39 ms 48560 KB Output is correct
59 Correct 198 ms 115316 KB Output is correct
60 Correct 184 ms 115288 KB Output is correct
61 Correct 206 ms 115196 KB Output is correct
62 Correct 19 ms 35732 KB Output is correct
63 Correct 194 ms 115028 KB Output is correct
64 Correct 74 ms 115300 KB Output is correct
65 Correct 90 ms 115404 KB Output is correct
66 Correct 78 ms 115336 KB Output is correct
67 Correct 63 ms 76132 KB Output is correct
68 Correct 71 ms 98516 KB Output is correct
69 Correct 96 ms 115272 KB Output is correct
70 Correct 24 ms 48604 KB Output is correct
71 Correct 25 ms 48632 KB Output is correct
72 Correct 23 ms 48588 KB Output is correct
73 Correct 23 ms 48612 KB Output is correct
74 Correct 29 ms 48596 KB Output is correct
75 Correct 34 ms 48584 KB Output is correct
76 Correct 28 ms 48564 KB Output is correct
77 Correct 24 ms 48568 KB Output is correct
78 Correct 24 ms 48588 KB Output is correct
79 Correct 25 ms 48584 KB Output is correct
80 Correct 23 ms 48580 KB Output is correct
81 Correct 25 ms 48588 KB Output is correct
82 Correct 24 ms 48564 KB Output is correct
83 Correct 24 ms 48660 KB Output is correct
84 Correct 23 ms 48592 KB Output is correct
85 Correct 24 ms 48584 KB Output is correct
86 Correct 26 ms 48564 KB Output is correct
87 Correct 31 ms 48588 KB Output is correct
88 Correct 30 ms 48596 KB Output is correct
89 Correct 26 ms 48548 KB Output is correct
90 Correct 28 ms 48560 KB Output is correct