Submission #969453

# Submission time Handle Problem Language Result Execution time Memory
969453 2024-04-25T07:38:37 Z batsukh2006 Dango Maker (JOI18_dango_maker) C++17
100 / 100
788 ms 18884 KB
#include<iostream>
#include<stdio.h>
#include<math.h>
#include<map>
#include<string>
#include<algorithm>
#include<vector>
#include<string.h>
#include<utility>
#include<set>
#include<cmath>
#include<queue>
#include<deque>
#include<functional>
#include<stack>
#include<limits.h>
#include<iomanip>
#include<unordered_map> 
#include<numeric>
#include<tuple>
using namespace std;
 
#define MOD 1000000007
#define int long long
#define endl '\n'
void solve(){
	int n,m; cin>>n>>m;
	vector<vector<char> > a(n+1,vector<char>(m+1));
	for(int i=1; i<=n; i++){
		for(int j=1; j<=m; j++){
			cin>>a[i][j];
		}
	}
	int ans=0;
	for(int z=2; z<=n+m; z++){
		int j=min(m,z-1),i=z-j;
		vector<vector<int> > dp(n+1,vector<int>(3));
		while(j>=1&&i<=n){
			dp[i][0]=max({dp[i-1][0],dp[i-1][1],dp[i-1][2]});
			if(a[i][j]=='G'){
				if(j>1&&j<m){
					if(a[i][j-1]=='R'&&a[i][j+1]=='W'){
						dp[i][1]=max(dp[i-1][0],dp[i-1][1])+1;
					}
				}
				if(i>1&&i<n){
					if(a[i-1][j]=='R'&&a[i+1][j]=='W'){
						dp[i][2]=max(dp[i-1][0],dp[i-1][2])+1;
					}
				}
			}
			i++,j--;
		}
		ans+=max({dp[i-1][0],dp[i-1][1],dp[i-1][2]});
	}
	cout<<ans;
}
signed main(){
    // freopen("248.in", "r", stdin);
    // freopen("248.out", "w", stdout);
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    
    int t=1;
//    cin>>t;	
    while(t--){
        solve();
        cout<<endl;
    }
    return 0;
}
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 1 ms 344 KB Output is correct
10 Correct 1 ms 344 KB Output is correct
11 Correct 0 ms 344 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 0 ms 344 KB Output is correct
14 Correct 1 ms 344 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 1 ms 344 KB Output is correct
10 Correct 1 ms 344 KB Output is correct
11 Correct 0 ms 344 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 0 ms 344 KB Output is correct
14 Correct 1 ms 344 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
17 Correct 1 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 344 KB Output is correct
21 Correct 0 ms 344 KB Output is correct
22 Correct 1 ms 348 KB Output is correct
23 Correct 1 ms 348 KB Output is correct
24 Correct 1 ms 348 KB Output is correct
25 Correct 0 ms 348 KB Output is correct
26 Correct 1 ms 348 KB Output is correct
27 Correct 1 ms 360 KB Output is correct
28 Correct 0 ms 348 KB Output is correct
29 Correct 1 ms 348 KB Output is correct
30 Correct 0 ms 348 KB Output is correct
31 Correct 1 ms 348 KB Output is correct
32 Correct 0 ms 348 KB Output is correct
33 Correct 1 ms 348 KB Output is correct
34 Correct 0 ms 348 KB Output is correct
35 Correct 0 ms 348 KB Output is correct
36 Correct 1 ms 348 KB Output is correct
37 Correct 0 ms 344 KB Output is correct
38 Correct 0 ms 348 KB Output is correct
39 Correct 1 ms 452 KB Output is correct
40 Correct 1 ms 348 KB Output is correct
41 Correct 0 ms 348 KB Output is correct
42 Correct 0 ms 348 KB Output is correct
43 Correct 0 ms 348 KB Output is correct
44 Correct 0 ms 348 KB Output is correct
45 Correct 0 ms 456 KB Output is correct
46 Correct 0 ms 348 KB Output is correct
47 Correct 0 ms 348 KB Output is correct
48 Correct 1 ms 348 KB Output is correct
49 Correct 0 ms 348 KB Output is correct
50 Correct 0 ms 352 KB Output is correct
51 Correct 1 ms 348 KB Output is correct
52 Correct 0 ms 344 KB Output is correct
53 Correct 1 ms 352 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 1 ms 344 KB Output is correct
10 Correct 1 ms 344 KB Output is correct
11 Correct 0 ms 344 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 0 ms 344 KB Output is correct
14 Correct 1 ms 344 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
17 Correct 1 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 344 KB Output is correct
21 Correct 0 ms 344 KB Output is correct
22 Correct 1 ms 348 KB Output is correct
23 Correct 1 ms 348 KB Output is correct
24 Correct 1 ms 348 KB Output is correct
25 Correct 0 ms 348 KB Output is correct
26 Correct 1 ms 348 KB Output is correct
27 Correct 1 ms 360 KB Output is correct
28 Correct 0 ms 348 KB Output is correct
29 Correct 1 ms 348 KB Output is correct
30 Correct 0 ms 348 KB Output is correct
31 Correct 1 ms 348 KB Output is correct
32 Correct 0 ms 348 KB Output is correct
33 Correct 1 ms 348 KB Output is correct
34 Correct 0 ms 348 KB Output is correct
35 Correct 0 ms 348 KB Output is correct
36 Correct 1 ms 348 KB Output is correct
37 Correct 0 ms 344 KB Output is correct
38 Correct 0 ms 348 KB Output is correct
39 Correct 1 ms 452 KB Output is correct
40 Correct 1 ms 348 KB Output is correct
41 Correct 0 ms 348 KB Output is correct
42 Correct 0 ms 348 KB Output is correct
43 Correct 0 ms 348 KB Output is correct
44 Correct 0 ms 348 KB Output is correct
45 Correct 0 ms 456 KB Output is correct
46 Correct 0 ms 348 KB Output is correct
47 Correct 0 ms 348 KB Output is correct
48 Correct 1 ms 348 KB Output is correct
49 Correct 0 ms 348 KB Output is correct
50 Correct 0 ms 352 KB Output is correct
51 Correct 1 ms 348 KB Output is correct
52 Correct 0 ms 344 KB Output is correct
53 Correct 1 ms 352 KB Output is correct
54 Correct 1 ms 344 KB Output is correct
55 Correct 254 ms 604 KB Output is correct
56 Correct 1 ms 344 KB Output is correct
57 Correct 116 ms 672 KB Output is correct
58 Correct 78 ms 2644 KB Output is correct
59 Correct 756 ms 18356 KB Output is correct
60 Correct 788 ms 18364 KB Output is correct
61 Correct 759 ms 18344 KB Output is correct
62 Correct 1 ms 344 KB Output is correct
63 Correct 749 ms 17984 KB Output is correct
64 Correct 756 ms 18664 KB Output is correct
65 Correct 717 ms 18512 KB Output is correct
66 Correct 779 ms 18324 KB Output is correct
67 Correct 720 ms 18884 KB Output is correct
68 Correct 776 ms 18668 KB Output is correct
69 Correct 768 ms 18516 KB Output is correct
70 Correct 78 ms 2392 KB Output is correct
71 Correct 70 ms 2392 KB Output is correct
72 Correct 88 ms 2396 KB Output is correct
73 Correct 70 ms 2396 KB Output is correct
74 Correct 72 ms 2500 KB Output is correct
75 Correct 75 ms 2492 KB Output is correct
76 Correct 73 ms 2396 KB Output is correct
77 Correct 80 ms 2396 KB Output is correct
78 Correct 72 ms 2396 KB Output is correct
79 Correct 80 ms 2364 KB Output is correct
80 Correct 72 ms 2396 KB Output is correct
81 Correct 81 ms 2392 KB Output is correct
82 Correct 79 ms 2496 KB Output is correct
83 Correct 79 ms 2500 KB Output is correct
84 Correct 70 ms 2392 KB Output is correct
85 Correct 73 ms 2492 KB Output is correct
86 Correct 71 ms 2396 KB Output is correct
87 Correct 71 ms 2396 KB Output is correct
88 Correct 75 ms 2396 KB Output is correct
89 Correct 72 ms 2392 KB Output is correct
90 Correct 72 ms 2260 KB Output is correct