답안 #538385

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
538385 2022-03-16T17:42:51 Z new_acc Dango Maker (JOI18_dango_maker) C++14
100 / 100
655 ms 35340 KB
#include<bits/stdc++.h>
#define fi first
#define se second
#define pitem item*
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
const int N=3e3+10;
bool ok[N][N][2];
char t[N][N];
int dp[N][4];
int n,m;
int diag(int a,int b){
	int k=0;
	while(a>0 and b<=m){
		k++;
		dp[k][0]=max(dp[k-1][3],dp[k-1][0])+ok[a][b][0];
		dp[k][1]=max({dp[k-1][2],dp[k-1][1],dp[k-1][0],dp[k-1][3]})+ok[a][b][1];
		dp[k][2]=dp[k-1][1],dp[k][3]=dp[k-1][2];
		a--,b++;
	}
	return max({dp[k][0],dp[k][1],dp[k][2],dp[k][3]});
}
void solve(){
	cin>>n>>m;
	for(int i=1;i<=n;i++)
		for(int j=1;j<=m;j++) cin>>t[i][j];
	for(int i=1;i<=n;i++){
		for(int j=1;j<=m;j++){
			if(t[i][j]=='R'){
				if(i+2<=n and t[i+1][j]=='G' and t[i+2][j]=='W') ok[i][j][0]=1;
				if(j+2<=m and t[i][j+1]=='G' and t[i][j+2]=='W') ok[i][j][1]=1;
			}
		}
	}
	int res=0;
	for(int i=1;i<=n;i++) res+=diag(i,1);
	for(int i=2;i<=m;i++) res+=diag(n,i);
	cout<<res<<"\n";
}
int main(){
	solve();
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 0 ms 340 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 1 ms 340 KB Output is correct
12 Correct 1 ms 340 KB Output is correct
13 Correct 0 ms 340 KB Output is correct
14 Correct 1 ms 304 KB Output is correct
15 Correct 1 ms 212 KB Output is correct
16 Correct 1 ms 304 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 0 ms 340 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 1 ms 340 KB Output is correct
12 Correct 1 ms 340 KB Output is correct
13 Correct 0 ms 340 KB Output is correct
14 Correct 1 ms 304 KB Output is correct
15 Correct 1 ms 212 KB Output is correct
16 Correct 1 ms 304 KB Output is correct
17 Correct 1 ms 340 KB Output is correct
18 Correct 1 ms 340 KB Output is correct
19 Correct 1 ms 340 KB Output is correct
20 Correct 1 ms 340 KB Output is correct
21 Correct 1 ms 340 KB Output is correct
22 Correct 1 ms 304 KB Output is correct
23 Correct 1 ms 340 KB Output is correct
24 Correct 1 ms 340 KB Output is correct
25 Correct 1 ms 340 KB Output is correct
26 Correct 1 ms 212 KB Output is correct
27 Correct 1 ms 308 KB Output is correct
28 Correct 1 ms 340 KB Output is correct
29 Correct 1 ms 340 KB Output is correct
30 Correct 1 ms 304 KB Output is correct
31 Correct 1 ms 340 KB Output is correct
32 Correct 1 ms 340 KB Output is correct
33 Correct 1 ms 340 KB Output is correct
34 Correct 0 ms 340 KB Output is correct
35 Correct 1 ms 340 KB Output is correct
36 Correct 1 ms 340 KB Output is correct
37 Correct 1 ms 308 KB Output is correct
38 Correct 0 ms 340 KB Output is correct
39 Correct 1 ms 308 KB Output is correct
40 Correct 1 ms 340 KB Output is correct
41 Correct 1 ms 316 KB Output is correct
42 Correct 0 ms 340 KB Output is correct
43 Correct 1 ms 340 KB Output is correct
44 Correct 1 ms 340 KB Output is correct
45 Correct 1 ms 308 KB Output is correct
46 Correct 0 ms 340 KB Output is correct
47 Correct 1 ms 308 KB Output is correct
48 Correct 1 ms 340 KB Output is correct
49 Correct 1 ms 340 KB Output is correct
50 Correct 1 ms 312 KB Output is correct
51 Correct 1 ms 340 KB Output is correct
52 Correct 1 ms 304 KB Output is correct
53 Correct 1 ms 340 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 0 ms 340 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 1 ms 340 KB Output is correct
12 Correct 1 ms 340 KB Output is correct
13 Correct 0 ms 340 KB Output is correct
14 Correct 1 ms 304 KB Output is correct
15 Correct 1 ms 212 KB Output is correct
16 Correct 1 ms 304 KB Output is correct
17 Correct 1 ms 340 KB Output is correct
18 Correct 1 ms 340 KB Output is correct
19 Correct 1 ms 340 KB Output is correct
20 Correct 1 ms 340 KB Output is correct
21 Correct 1 ms 340 KB Output is correct
22 Correct 1 ms 304 KB Output is correct
23 Correct 1 ms 340 KB Output is correct
24 Correct 1 ms 340 KB Output is correct
25 Correct 1 ms 340 KB Output is correct
26 Correct 1 ms 212 KB Output is correct
27 Correct 1 ms 308 KB Output is correct
28 Correct 1 ms 340 KB Output is correct
29 Correct 1 ms 340 KB Output is correct
30 Correct 1 ms 304 KB Output is correct
31 Correct 1 ms 340 KB Output is correct
32 Correct 1 ms 340 KB Output is correct
33 Correct 1 ms 340 KB Output is correct
34 Correct 0 ms 340 KB Output is correct
35 Correct 1 ms 340 KB Output is correct
36 Correct 1 ms 340 KB Output is correct
37 Correct 1 ms 308 KB Output is correct
38 Correct 0 ms 340 KB Output is correct
39 Correct 1 ms 308 KB Output is correct
40 Correct 1 ms 340 KB Output is correct
41 Correct 1 ms 316 KB Output is correct
42 Correct 0 ms 340 KB Output is correct
43 Correct 1 ms 340 KB Output is correct
44 Correct 1 ms 340 KB Output is correct
45 Correct 1 ms 308 KB Output is correct
46 Correct 0 ms 340 KB Output is correct
47 Correct 1 ms 308 KB Output is correct
48 Correct 1 ms 340 KB Output is correct
49 Correct 1 ms 340 KB Output is correct
50 Correct 1 ms 312 KB Output is correct
51 Correct 1 ms 340 KB Output is correct
52 Correct 1 ms 304 KB Output is correct
53 Correct 1 ms 340 KB Output is correct
54 Correct 1 ms 212 KB Output is correct
55 Correct 6 ms 9592 KB Output is correct
56 Correct 2 ms 340 KB Output is correct
57 Correct 7 ms 13268 KB Output is correct
58 Correct 72 ms 10040 KB Output is correct
59 Correct 640 ms 35236 KB Output is correct
60 Correct 644 ms 35288 KB Output is correct
61 Correct 642 ms 35232 KB Output is correct
62 Correct 1 ms 340 KB Output is correct
63 Correct 630 ms 34972 KB Output is correct
64 Correct 655 ms 35340 KB Output is correct
65 Correct 610 ms 35276 KB Output is correct
66 Correct 593 ms 35264 KB Output is correct
67 Correct 575 ms 27468 KB Output is correct
68 Correct 572 ms 27612 KB Output is correct
69 Correct 586 ms 31164 KB Output is correct
70 Correct 66 ms 10112 KB Output is correct
71 Correct 66 ms 10132 KB Output is correct
72 Correct 69 ms 10028 KB Output is correct
73 Correct 67 ms 10132 KB Output is correct
74 Correct 69 ms 10124 KB Output is correct
75 Correct 68 ms 10164 KB Output is correct
76 Correct 69 ms 10204 KB Output is correct
77 Correct 67 ms 10040 KB Output is correct
78 Correct 73 ms 10052 KB Output is correct
79 Correct 66 ms 10092 KB Output is correct
80 Correct 65 ms 10040 KB Output is correct
81 Correct 64 ms 10064 KB Output is correct
82 Correct 66 ms 10060 KB Output is correct
83 Correct 66 ms 10108 KB Output is correct
84 Correct 65 ms 10132 KB Output is correct
85 Correct 64 ms 10060 KB Output is correct
86 Correct 66 ms 10056 KB Output is correct
87 Correct 68 ms 10064 KB Output is correct
88 Correct 66 ms 10092 KB Output is correct
89 Correct 66 ms 10056 KB Output is correct
90 Correct 64 ms 10096 KB Output is correct