Submission #210004

# Submission time Handle Problem Language Result Execution time Memory
210004 2020-03-16T08:55:06 Z kshitij_sodani Dango Maker (JOI18_dango_maker) C++17
100 / 100
498 ms 44536 KB
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
#define mp make_pair
#define pb push_back
typedef int64_t llo;
#define a first
#define  b second
#define endl "\n"
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int n,m;
	cin>>n>>m;
	int it[n][m];
	char s;
	for(int i=0;i<n;i++){
		for(int j=0;j<m;j++){
			cin>>s;
			if(s=='R'){
				it[i][j]=0;
			}
			else if(s=='G'){
				it[i][j]=1;
			}
			else{
				it[i][j]=2;
			}
		}
	}
	int tot=0;
	for(int ii=0;ii<n+m-1;ii++){
		
		vector<pair<int,int>> aa;
		for(int jj=0;jj<ii+1;jj++){

			int i,j;
			j=jj;
			i=ii-j;
			int co=0;
			int co2=0;
			if(i>=n or j>=m){
				continue;
			}
			int st=1;
			int stt=1;
			if(j>0  and it[i][j-1]==0 and j+1<m and it[i][j+1]==2 and it[i][j]==1){
				co+=1;
			}
		
			if(i>0 and i+1<n and it[i-1][j]==0 and it[i+1][j]==2 and it[i][j]==1){
				co2+=1;
			}
			aa.pb({co,co2});
		}
		pair<int,int> dp[aa.size()];
		dp[0]=aa[0];
		for(int k=1;k<aa.size();k++){
			dp[k]=dp[k-1];
			if(aa[k].a==1){
				dp[k].a+=1;
				if(k>1){
					dp[k].a=max(dp[k].a,dp[k-2].b+1);
				}

			}
			if(aa[k].b==1){
				dp[k].b+=1;
				if(k>1){
					dp[k].b=max(dp[k].b,dp[k-2].a+1);
				}
				
			}

		}
		tot+=max(dp[aa.size()-1].a,dp[aa.size()-1].b);
		

	}

	cout<<tot<<endl;






	return 0;
}

Compilation message

dango_maker.cpp: In function 'int main()':
dango_maker.cpp:45:8: warning: unused variable 'st' [-Wunused-variable]
    int st=1;
        ^~
dango_maker.cpp:46:8: warning: unused variable 'stt' [-Wunused-variable]
    int stt=1;
        ^~~
dango_maker.cpp:58:16: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   for(int k=1;k<aa.size();k++){
               ~^~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 5 ms 248 KB Output is correct
2 Correct 5 ms 376 KB Output is correct
3 Correct 5 ms 376 KB Output is correct
4 Correct 4 ms 376 KB Output is correct
5 Correct 5 ms 376 KB Output is correct
6 Correct 4 ms 376 KB Output is correct
7 Correct 4 ms 376 KB Output is correct
8 Correct 5 ms 376 KB Output is correct
9 Correct 4 ms 376 KB Output is correct
10 Correct 5 ms 376 KB Output is correct
11 Correct 5 ms 376 KB Output is correct
12 Correct 5 ms 376 KB Output is correct
13 Correct 4 ms 376 KB Output is correct
14 Correct 5 ms 376 KB Output is correct
15 Correct 5 ms 376 KB Output is correct
16 Correct 5 ms 376 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 248 KB Output is correct
2 Correct 5 ms 376 KB Output is correct
3 Correct 5 ms 376 KB Output is correct
4 Correct 4 ms 376 KB Output is correct
5 Correct 5 ms 376 KB Output is correct
6 Correct 4 ms 376 KB Output is correct
7 Correct 4 ms 376 KB Output is correct
8 Correct 5 ms 376 KB Output is correct
9 Correct 4 ms 376 KB Output is correct
10 Correct 5 ms 376 KB Output is correct
11 Correct 5 ms 376 KB Output is correct
12 Correct 5 ms 376 KB Output is correct
13 Correct 4 ms 376 KB Output is correct
14 Correct 5 ms 376 KB Output is correct
15 Correct 5 ms 376 KB Output is correct
16 Correct 5 ms 376 KB Output is correct
17 Correct 5 ms 424 KB Output is correct
18 Correct 5 ms 376 KB Output is correct
19 Correct 5 ms 376 KB Output is correct
20 Correct 5 ms 376 KB Output is correct
21 Correct 5 ms 384 KB Output is correct
22 Correct 4 ms 376 KB Output is correct
23 Correct 5 ms 376 KB Output is correct
24 Correct 5 ms 376 KB Output is correct
25 Correct 5 ms 376 KB Output is correct
26 Correct 5 ms 376 KB Output is correct
27 Correct 5 ms 376 KB Output is correct
28 Correct 5 ms 376 KB Output is correct
29 Correct 5 ms 376 KB Output is correct
30 Correct 5 ms 376 KB Output is correct
31 Correct 5 ms 376 KB Output is correct
32 Correct 4 ms 376 KB Output is correct
33 Correct 5 ms 376 KB Output is correct
34 Correct 5 ms 380 KB Output is correct
35 Correct 5 ms 376 KB Output is correct
36 Correct 5 ms 376 KB Output is correct
37 Correct 5 ms 376 KB Output is correct
38 Correct 5 ms 380 KB Output is correct
39 Correct 5 ms 376 KB Output is correct
40 Correct 5 ms 376 KB Output is correct
41 Correct 5 ms 376 KB Output is correct
42 Correct 5 ms 376 KB Output is correct
43 Correct 5 ms 376 KB Output is correct
44 Correct 5 ms 252 KB Output is correct
45 Correct 5 ms 376 KB Output is correct
46 Correct 5 ms 376 KB Output is correct
47 Correct 5 ms 376 KB Output is correct
48 Correct 5 ms 376 KB Output is correct
49 Correct 5 ms 376 KB Output is correct
50 Correct 5 ms 376 KB Output is correct
51 Correct 5 ms 376 KB Output is correct
52 Correct 5 ms 376 KB Output is correct
53 Correct 5 ms 376 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 248 KB Output is correct
2 Correct 5 ms 376 KB Output is correct
3 Correct 5 ms 376 KB Output is correct
4 Correct 4 ms 376 KB Output is correct
5 Correct 5 ms 376 KB Output is correct
6 Correct 4 ms 376 KB Output is correct
7 Correct 4 ms 376 KB Output is correct
8 Correct 5 ms 376 KB Output is correct
9 Correct 4 ms 376 KB Output is correct
10 Correct 5 ms 376 KB Output is correct
11 Correct 5 ms 376 KB Output is correct
12 Correct 5 ms 376 KB Output is correct
13 Correct 4 ms 376 KB Output is correct
14 Correct 5 ms 376 KB Output is correct
15 Correct 5 ms 376 KB Output is correct
16 Correct 5 ms 376 KB Output is correct
17 Correct 5 ms 424 KB Output is correct
18 Correct 5 ms 376 KB Output is correct
19 Correct 5 ms 376 KB Output is correct
20 Correct 5 ms 376 KB Output is correct
21 Correct 5 ms 384 KB Output is correct
22 Correct 4 ms 376 KB Output is correct
23 Correct 5 ms 376 KB Output is correct
24 Correct 5 ms 376 KB Output is correct
25 Correct 5 ms 376 KB Output is correct
26 Correct 5 ms 376 KB Output is correct
27 Correct 5 ms 376 KB Output is correct
28 Correct 5 ms 376 KB Output is correct
29 Correct 5 ms 376 KB Output is correct
30 Correct 5 ms 376 KB Output is correct
31 Correct 5 ms 376 KB Output is correct
32 Correct 4 ms 376 KB Output is correct
33 Correct 5 ms 376 KB Output is correct
34 Correct 5 ms 380 KB Output is correct
35 Correct 5 ms 376 KB Output is correct
36 Correct 5 ms 376 KB Output is correct
37 Correct 5 ms 376 KB Output is correct
38 Correct 5 ms 380 KB Output is correct
39 Correct 5 ms 376 KB Output is correct
40 Correct 5 ms 376 KB Output is correct
41 Correct 5 ms 376 KB Output is correct
42 Correct 5 ms 376 KB Output is correct
43 Correct 5 ms 376 KB Output is correct
44 Correct 5 ms 252 KB Output is correct
45 Correct 5 ms 376 KB Output is correct
46 Correct 5 ms 376 KB Output is correct
47 Correct 5 ms 376 KB Output is correct
48 Correct 5 ms 376 KB Output is correct
49 Correct 5 ms 376 KB Output is correct
50 Correct 5 ms 376 KB Output is correct
51 Correct 5 ms 376 KB Output is correct
52 Correct 5 ms 376 KB Output is correct
53 Correct 5 ms 376 KB Output is correct
54 Correct 9 ms 376 KB Output is correct
55 Correct 9 ms 376 KB Output is correct
56 Correct 10 ms 376 KB Output is correct
57 Correct 8 ms 376 KB Output is correct
58 Correct 54 ms 5240 KB Output is correct
59 Correct 498 ms 44452 KB Output is correct
60 Correct 498 ms 44408 KB Output is correct
61 Correct 489 ms 44484 KB Output is correct
62 Correct 9 ms 376 KB Output is correct
63 Correct 476 ms 42976 KB Output is correct
64 Correct 335 ms 44536 KB Output is correct
65 Correct 331 ms 44408 KB Output is correct
66 Correct 346 ms 44392 KB Output is correct
67 Correct 338 ms 44412 KB Output is correct
68 Correct 359 ms 44432 KB Output is correct
69 Correct 356 ms 44408 KB Output is correct
70 Correct 42 ms 5240 KB Output is correct
71 Correct 41 ms 5240 KB Output is correct
72 Correct 41 ms 5240 KB Output is correct
73 Correct 40 ms 5236 KB Output is correct
74 Correct 41 ms 5240 KB Output is correct
75 Correct 40 ms 5240 KB Output is correct
76 Correct 42 ms 5240 KB Output is correct
77 Correct 41 ms 5240 KB Output is correct
78 Correct 40 ms 5240 KB Output is correct
79 Correct 41 ms 5240 KB Output is correct
80 Correct 41 ms 5240 KB Output is correct
81 Correct 41 ms 5240 KB Output is correct
82 Correct 41 ms 5240 KB Output is correct
83 Correct 42 ms 5240 KB Output is correct
84 Correct 40 ms 5240 KB Output is correct
85 Correct 41 ms 5240 KB Output is correct
86 Correct 41 ms 5240 KB Output is correct
87 Correct 40 ms 5240 KB Output is correct
88 Correct 41 ms 5240 KB Output is correct
89 Correct 41 ms 5240 KB Output is correct
90 Correct 41 ms 5240 KB Output is correct