Submission #66886

# Submission time Handle Problem Language Result Execution time Memory
66886 2018-08-12T18:17:29 Z hamzqq9 Dango Maker (JOI18_dango_maker) C++14
100 / 100
882 ms 97816 KB
#include<bits/stdc++.h>
#define st first
#define nd second
#define pb push_back
#define ppb pop_back
#define umax(x,y) x=max(x,y)
#define umin(x,y) x=min(x,y)
#define ll long long
#define ii pair<int,int>
#define iii pair<int,ii>
#define sz(x) ((int) x.size())
#define orta ((bas+son)>>1)
#define all(x) x.begin(),x.end()
#define dbgs(x) cerr<<(#x)<<" --> "<<(x)<<" "
#define dbg(x) cerr<<(#x)<<" --> "<<(x)<<endl;getchar()
#define pw(x) (1<<(x))
#define inf 100000000000000
#define MOD 1000000007
#define N 3005
#define MAX 10000006
#define LOG 22
using namespace std;

int n,m,ans;
int dp[N][N][2];
bool node[N][N][2];
char a[N][N];

int main() {
 
	//freopen("input.txt","r",stdin);
 
	scanf("%d %d",&n,&m);

	for(int i=1;i<=n;i++) {

		for(int j=1;j<=m;j++) {

			scanf(" %c",&a[i][j]);

		}

	}

	// 0 vertical 1 horizontal

	for(int i=1;i<=n;i++) {

		if(i>1 && i<n) {

			for(int j=1;j<=m;j++) {

				if(a[i-1][j]=='R' && a[i][j]=='G' && a[i+1][j]=='W') node[i][j][0]=1;

			}

		}

		for(int j=2;j<=m;j++) {

			if(a[i][j-1]=='R' && a[i][j]=='G' && a[i][j+1]=='W') node[i][j][1]=1;

		}

	}

	for(int i=n;i>=1;i--) {

		for(int j=1;j<=m;j++) {

			dp[i][j][0]=max(dp[i+1][j-1][1],dp[i+1][j-1][0]+node[i][j][0]);
			dp[i][j][1]=max(dp[i+1][j-1][0],dp[i+1][j-1][1]+node[i][j][1]);

		}

	}

	for(int i=1;i<=m;i++) ans+=max(dp[1][i][0],dp[1][i][1]);

	for(int i=2;i<=n;i++) ans+=max(dp[i][m][0],dp[i][m][1]);

	printf("%d",ans);

} 	
 

Compilation message

dango_maker.cpp: In function 'int main()':
dango_maker.cpp:33:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d %d",&n,&m);
  ~~~~~^~~~~~~~~~~~~~~
dango_maker.cpp:39:9: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
    scanf(" %c",&a[i][j]);
    ~~~~~^~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 2 ms 248 KB Output is correct
2 Correct 2 ms 484 KB Output is correct
3 Correct 2 ms 572 KB Output is correct
4 Correct 2 ms 572 KB Output is correct
5 Correct 3 ms 572 KB Output is correct
6 Correct 2 ms 572 KB Output is correct
7 Correct 2 ms 632 KB Output is correct
8 Correct 2 ms 632 KB Output is correct
9 Correct 3 ms 632 KB Output is correct
10 Correct 3 ms 632 KB Output is correct
11 Correct 2 ms 632 KB Output is correct
12 Correct 2 ms 632 KB Output is correct
13 Correct 2 ms 632 KB Output is correct
14 Correct 2 ms 632 KB Output is correct
15 Correct 2 ms 632 KB Output is correct
16 Correct 2 ms 632 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 248 KB Output is correct
2 Correct 2 ms 484 KB Output is correct
3 Correct 2 ms 572 KB Output is correct
4 Correct 2 ms 572 KB Output is correct
5 Correct 3 ms 572 KB Output is correct
6 Correct 2 ms 572 KB Output is correct
7 Correct 2 ms 632 KB Output is correct
8 Correct 2 ms 632 KB Output is correct
9 Correct 3 ms 632 KB Output is correct
10 Correct 3 ms 632 KB Output is correct
11 Correct 2 ms 632 KB Output is correct
12 Correct 2 ms 632 KB Output is correct
13 Correct 2 ms 632 KB Output is correct
14 Correct 2 ms 632 KB Output is correct
15 Correct 2 ms 632 KB Output is correct
16 Correct 2 ms 632 KB Output is correct
17 Correct 3 ms 724 KB Output is correct
18 Correct 2 ms 724 KB Output is correct
19 Correct 2 ms 724 KB Output is correct
20 Correct 3 ms 724 KB Output is correct
21 Correct 2 ms 748 KB Output is correct
22 Correct 3 ms 748 KB Output is correct
23 Correct 3 ms 748 KB Output is correct
24 Correct 3 ms 748 KB Output is correct
25 Correct 3 ms 748 KB Output is correct
26 Correct 2 ms 748 KB Output is correct
27 Correct 2 ms 748 KB Output is correct
28 Correct 2 ms 748 KB Output is correct
29 Correct 2 ms 748 KB Output is correct
30 Correct 3 ms 748 KB Output is correct
31 Correct 2 ms 748 KB Output is correct
32 Correct 2 ms 748 KB Output is correct
33 Correct 2 ms 748 KB Output is correct
34 Correct 3 ms 748 KB Output is correct
35 Correct 3 ms 748 KB Output is correct
36 Correct 3 ms 748 KB Output is correct
37 Correct 4 ms 748 KB Output is correct
38 Correct 2 ms 748 KB Output is correct
39 Correct 2 ms 748 KB Output is correct
40 Correct 2 ms 748 KB Output is correct
41 Correct 3 ms 748 KB Output is correct
42 Correct 2 ms 748 KB Output is correct
43 Correct 3 ms 748 KB Output is correct
44 Correct 2 ms 748 KB Output is correct
45 Correct 2 ms 748 KB Output is correct
46 Correct 2 ms 748 KB Output is correct
47 Correct 3 ms 748 KB Output is correct
48 Correct 3 ms 748 KB Output is correct
49 Correct 2 ms 748 KB Output is correct
50 Correct 3 ms 748 KB Output is correct
51 Correct 3 ms 748 KB Output is correct
52 Correct 3 ms 748 KB Output is correct
53 Correct 2 ms 748 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 248 KB Output is correct
2 Correct 2 ms 484 KB Output is correct
3 Correct 2 ms 572 KB Output is correct
4 Correct 2 ms 572 KB Output is correct
5 Correct 3 ms 572 KB Output is correct
6 Correct 2 ms 572 KB Output is correct
7 Correct 2 ms 632 KB Output is correct
8 Correct 2 ms 632 KB Output is correct
9 Correct 3 ms 632 KB Output is correct
10 Correct 3 ms 632 KB Output is correct
11 Correct 2 ms 632 KB Output is correct
12 Correct 2 ms 632 KB Output is correct
13 Correct 2 ms 632 KB Output is correct
14 Correct 2 ms 632 KB Output is correct
15 Correct 2 ms 632 KB Output is correct
16 Correct 2 ms 632 KB Output is correct
17 Correct 3 ms 724 KB Output is correct
18 Correct 2 ms 724 KB Output is correct
19 Correct 2 ms 724 KB Output is correct
20 Correct 3 ms 724 KB Output is correct
21 Correct 2 ms 748 KB Output is correct
22 Correct 3 ms 748 KB Output is correct
23 Correct 3 ms 748 KB Output is correct
24 Correct 3 ms 748 KB Output is correct
25 Correct 3 ms 748 KB Output is correct
26 Correct 2 ms 748 KB Output is correct
27 Correct 2 ms 748 KB Output is correct
28 Correct 2 ms 748 KB Output is correct
29 Correct 2 ms 748 KB Output is correct
30 Correct 3 ms 748 KB Output is correct
31 Correct 2 ms 748 KB Output is correct
32 Correct 2 ms 748 KB Output is correct
33 Correct 2 ms 748 KB Output is correct
34 Correct 3 ms 748 KB Output is correct
35 Correct 3 ms 748 KB Output is correct
36 Correct 3 ms 748 KB Output is correct
37 Correct 4 ms 748 KB Output is correct
38 Correct 2 ms 748 KB Output is correct
39 Correct 2 ms 748 KB Output is correct
40 Correct 2 ms 748 KB Output is correct
41 Correct 3 ms 748 KB Output is correct
42 Correct 2 ms 748 KB Output is correct
43 Correct 3 ms 748 KB Output is correct
44 Correct 2 ms 748 KB Output is correct
45 Correct 2 ms 748 KB Output is correct
46 Correct 2 ms 748 KB Output is correct
47 Correct 3 ms 748 KB Output is correct
48 Correct 3 ms 748 KB Output is correct
49 Correct 2 ms 748 KB Output is correct
50 Correct 3 ms 748 KB Output is correct
51 Correct 3 ms 748 KB Output is correct
52 Correct 3 ms 748 KB Output is correct
53 Correct 2 ms 748 KB Output is correct
54 Correct 3 ms 748 KB Output is correct
55 Correct 21 ms 22012 KB Output is correct
56 Correct 4 ms 22012 KB Output is correct
57 Correct 19 ms 22012 KB Output is correct
58 Correct 94 ms 22012 KB Output is correct
59 Correct 812 ms 97700 KB Output is correct
60 Correct 756 ms 97700 KB Output is correct
61 Correct 735 ms 97788 KB Output is correct
62 Correct 3 ms 97788 KB Output is correct
63 Correct 882 ms 97788 KB Output is correct
64 Correct 641 ms 97788 KB Output is correct
65 Correct 667 ms 97788 KB Output is correct
66 Correct 668 ms 97816 KB Output is correct
67 Correct 625 ms 97816 KB Output is correct
68 Correct 680 ms 97816 KB Output is correct
69 Correct 717 ms 97816 KB Output is correct
70 Correct 81 ms 97816 KB Output is correct
71 Correct 88 ms 97816 KB Output is correct
72 Correct 75 ms 97816 KB Output is correct
73 Correct 81 ms 97816 KB Output is correct
74 Correct 83 ms 97816 KB Output is correct
75 Correct 79 ms 97816 KB Output is correct
76 Correct 94 ms 97816 KB Output is correct
77 Correct 85 ms 97816 KB Output is correct
78 Correct 80 ms 97816 KB Output is correct
79 Correct 75 ms 97816 KB Output is correct
80 Correct 77 ms 97816 KB Output is correct
81 Correct 88 ms 97816 KB Output is correct
82 Correct 79 ms 97816 KB Output is correct
83 Correct 84 ms 97816 KB Output is correct
84 Correct 87 ms 97816 KB Output is correct
85 Correct 76 ms 97816 KB Output is correct
86 Correct 85 ms 97816 KB Output is correct
87 Correct 79 ms 97816 KB Output is correct
88 Correct 87 ms 97816 KB Output is correct
89 Correct 85 ms 97816 KB Output is correct
90 Correct 86 ms 97816 KB Output is correct