Submission #666756

# Submission time Handle Problem Language Result Execution time Memory
666756 2022-11-29T14:13:14 Z manizare Dango Maker (JOI18_dango_maker) C++14
100 / 100
799 ms 133028 KB
#include <bits/stdc++.h>
#define all(a) a.begin(),a.end() 
#define pb push_back
using namespace std ;
const int maxn = 3002 , maxq =1e5 , inf = 1e9 + 100 , mod = 1e9 + 7 ;
char c[maxn][maxn] ;
vector <int> G[maxq] ;
vector <pair <int , int > > vec[maxq] ;
int ans[2] ;
int dp[maxq][3] ;
bool mark[maxq] , u[maxn][maxn]  , t[maxn][maxn];
void dfs(int v , int k){
	mark[v] = 1;
	ans[k]++;
	for(int i = 0 ; i < (int)G[v].size() ; i++){
		int u = G[v][i] ;
		if(mark[u] == 1)continue ;
		dfs(u , k^1);  
	}
}
 
signed main(){
	int n , m ;
	cin >> n >> m ;
	for(int i = 1; i <= n ; i++){
		for(int j = 1; j <= m ; j++){
			cin >> c[i][j] ;
		}
	}
	int cnt = 0 ;
	for(int i =1 ; i <= n ; i++){
		for(int j = 1; j <= m ; j++){
			vec[i+j].pb({i,j});
			if(i <= (n-2) && c[i][j] == 'R' && c[i+1][j] == 'G' && c[i+2][j] == 'W'){
				t[i][j] = 1;
			}
			if(j <= (m-2) && c[i][j] == 'R' && c[i][j+1] == 'G' && c[i][j+2] == 'W'){
				u[i][j] = 1 ;
			}
		}
	}
	int ans1 = 0 ;
	for(int i =  2; i <= (n+m) ; i++){
		for(int j = 1 ; j <= vec[i].size() ; j++){
			int x = vec[i][j-1].first , y = vec[i][j-1].second ;
			dp[j][0] = max(dp[j-1][0] , max(dp[j-1][1] , dp[j-1][2]));
			dp[j][1] = dp[j][2] = 0 ;
			if(u[x][y] == 1){
				dp[j][1] = 1 + max(dp[j-1][1] , (j == 1 ? 0 : max(dp[j-2][1] , dp[j-2][0])));                           			
			}
			if(t[x][y] == 1){
				dp[j][2] = 1 + max(dp[j-1][0] , max(dp[j-1][1] , dp[j-1][2]));
			}
		}
		int j = vec[i].size() ; 
		ans1 += max(dp[j][0] , max(dp[j][1] , dp[j][2]));
	}
	cout << ans1 << "\n";
}

Compilation message

dango_maker.cpp: In function 'int main()':
dango_maker.cpp:44:21: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   44 |   for(int j = 1 ; j <= vec[i].size() ; j++){
      |                   ~~^~~~~~~~~~~~~~~~
dango_maker.cpp:30:6: warning: unused variable 'cnt' [-Wunused-variable]
   30 |  int cnt = 0 ;
      |      ^~~
# Verdict Execution time Memory Grader output
1 Correct 3 ms 5076 KB Output is correct
2 Correct 3 ms 4948 KB Output is correct
3 Correct 3 ms 4948 KB Output is correct
4 Correct 3 ms 5004 KB Output is correct
5 Correct 3 ms 5012 KB Output is correct
6 Correct 3 ms 4948 KB Output is correct
7 Correct 3 ms 5012 KB Output is correct
8 Correct 2 ms 4948 KB Output is correct
9 Correct 3 ms 4948 KB Output is correct
10 Correct 3 ms 4948 KB Output is correct
11 Correct 3 ms 4948 KB Output is correct
12 Correct 3 ms 5008 KB Output is correct
13 Correct 3 ms 4948 KB Output is correct
14 Correct 3 ms 5008 KB Output is correct
15 Correct 4 ms 5012 KB Output is correct
16 Correct 3 ms 5072 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 5076 KB Output is correct
2 Correct 3 ms 4948 KB Output is correct
3 Correct 3 ms 4948 KB Output is correct
4 Correct 3 ms 5004 KB Output is correct
5 Correct 3 ms 5012 KB Output is correct
6 Correct 3 ms 4948 KB Output is correct
7 Correct 3 ms 5012 KB Output is correct
8 Correct 2 ms 4948 KB Output is correct
9 Correct 3 ms 4948 KB Output is correct
10 Correct 3 ms 4948 KB Output is correct
11 Correct 3 ms 4948 KB Output is correct
12 Correct 3 ms 5008 KB Output is correct
13 Correct 3 ms 4948 KB Output is correct
14 Correct 3 ms 5008 KB Output is correct
15 Correct 4 ms 5012 KB Output is correct
16 Correct 3 ms 5072 KB Output is correct
17 Correct 2 ms 4948 KB Output is correct
18 Correct 3 ms 5016 KB Output is correct
19 Correct 3 ms 5076 KB Output is correct
20 Correct 3 ms 5076 KB Output is correct
21 Correct 3 ms 5016 KB Output is correct
22 Correct 3 ms 5076 KB Output is correct
23 Correct 3 ms 5012 KB Output is correct
24 Correct 3 ms 5012 KB Output is correct
25 Correct 3 ms 4948 KB Output is correct
26 Correct 3 ms 5012 KB Output is correct
27 Correct 3 ms 5076 KB Output is correct
28 Correct 3 ms 5076 KB Output is correct
29 Correct 3 ms 5008 KB Output is correct
30 Correct 3 ms 5012 KB Output is correct
31 Correct 3 ms 5012 KB Output is correct
32 Correct 3 ms 5012 KB Output is correct
33 Correct 3 ms 5076 KB Output is correct
34 Correct 3 ms 5076 KB Output is correct
35 Correct 3 ms 5076 KB Output is correct
36 Correct 3 ms 5076 KB Output is correct
37 Correct 3 ms 5076 KB Output is correct
38 Correct 3 ms 5076 KB Output is correct
39 Correct 3 ms 5012 KB Output is correct
40 Correct 3 ms 5076 KB Output is correct
41 Correct 3 ms 5008 KB Output is correct
42 Correct 3 ms 5076 KB Output is correct
43 Correct 3 ms 5012 KB Output is correct
44 Correct 3 ms 5076 KB Output is correct
45 Correct 3 ms 5076 KB Output is correct
46 Correct 3 ms 5076 KB Output is correct
47 Correct 3 ms 5076 KB Output is correct
48 Correct 3 ms 5076 KB Output is correct
49 Correct 3 ms 5076 KB Output is correct
50 Correct 3 ms 5076 KB Output is correct
51 Correct 3 ms 5016 KB Output is correct
52 Correct 3 ms 5012 KB Output is correct
53 Correct 3 ms 5076 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 5076 KB Output is correct
2 Correct 3 ms 4948 KB Output is correct
3 Correct 3 ms 4948 KB Output is correct
4 Correct 3 ms 5004 KB Output is correct
5 Correct 3 ms 5012 KB Output is correct
6 Correct 3 ms 4948 KB Output is correct
7 Correct 3 ms 5012 KB Output is correct
8 Correct 2 ms 4948 KB Output is correct
9 Correct 3 ms 4948 KB Output is correct
10 Correct 3 ms 4948 KB Output is correct
11 Correct 3 ms 4948 KB Output is correct
12 Correct 3 ms 5008 KB Output is correct
13 Correct 3 ms 4948 KB Output is correct
14 Correct 3 ms 5008 KB Output is correct
15 Correct 4 ms 5012 KB Output is correct
16 Correct 3 ms 5072 KB Output is correct
17 Correct 2 ms 4948 KB Output is correct
18 Correct 3 ms 5016 KB Output is correct
19 Correct 3 ms 5076 KB Output is correct
20 Correct 3 ms 5076 KB Output is correct
21 Correct 3 ms 5016 KB Output is correct
22 Correct 3 ms 5076 KB Output is correct
23 Correct 3 ms 5012 KB Output is correct
24 Correct 3 ms 5012 KB Output is correct
25 Correct 3 ms 4948 KB Output is correct
26 Correct 3 ms 5012 KB Output is correct
27 Correct 3 ms 5076 KB Output is correct
28 Correct 3 ms 5076 KB Output is correct
29 Correct 3 ms 5008 KB Output is correct
30 Correct 3 ms 5012 KB Output is correct
31 Correct 3 ms 5012 KB Output is correct
32 Correct 3 ms 5012 KB Output is correct
33 Correct 3 ms 5076 KB Output is correct
34 Correct 3 ms 5076 KB Output is correct
35 Correct 3 ms 5076 KB Output is correct
36 Correct 3 ms 5076 KB Output is correct
37 Correct 3 ms 5076 KB Output is correct
38 Correct 3 ms 5076 KB Output is correct
39 Correct 3 ms 5012 KB Output is correct
40 Correct 3 ms 5076 KB Output is correct
41 Correct 3 ms 5008 KB Output is correct
42 Correct 3 ms 5076 KB Output is correct
43 Correct 3 ms 5012 KB Output is correct
44 Correct 3 ms 5076 KB Output is correct
45 Correct 3 ms 5076 KB Output is correct
46 Correct 3 ms 5076 KB Output is correct
47 Correct 3 ms 5076 KB Output is correct
48 Correct 3 ms 5076 KB Output is correct
49 Correct 3 ms 5076 KB Output is correct
50 Correct 3 ms 5076 KB Output is correct
51 Correct 3 ms 5016 KB Output is correct
52 Correct 3 ms 5012 KB Output is correct
53 Correct 3 ms 5076 KB Output is correct
54 Correct 3 ms 5076 KB Output is correct
55 Correct 9 ms 14360 KB Output is correct
56 Correct 5 ms 5332 KB Output is correct
57 Correct 11 ms 19284 KB Output is correct
58 Correct 88 ms 25416 KB Output is correct
59 Correct 713 ms 133028 KB Output is correct
60 Correct 708 ms 132896 KB Output is correct
61 Correct 728 ms 132900 KB Output is correct
62 Correct 4 ms 5076 KB Output is correct
63 Correct 702 ms 129484 KB Output is correct
64 Correct 786 ms 132908 KB Output is correct
65 Correct 794 ms 133004 KB Output is correct
66 Correct 799 ms 132836 KB Output is correct
67 Correct 777 ms 122400 KB Output is correct
68 Correct 748 ms 122340 KB Output is correct
69 Correct 721 ms 128668 KB Output is correct
70 Correct 81 ms 25400 KB Output is correct
71 Correct 83 ms 25412 KB Output is correct
72 Correct 82 ms 25360 KB Output is correct
73 Correct 82 ms 25380 KB Output is correct
74 Correct 82 ms 25368 KB Output is correct
75 Correct 81 ms 25372 KB Output is correct
76 Correct 86 ms 25412 KB Output is correct
77 Correct 80 ms 25368 KB Output is correct
78 Correct 82 ms 25452 KB Output is correct
79 Correct 81 ms 25364 KB Output is correct
80 Correct 82 ms 25420 KB Output is correct
81 Correct 81 ms 25524 KB Output is correct
82 Correct 81 ms 25404 KB Output is correct
83 Correct 84 ms 25468 KB Output is correct
84 Correct 81 ms 25424 KB Output is correct
85 Correct 81 ms 25428 KB Output is correct
86 Correct 82 ms 25408 KB Output is correct
87 Correct 81 ms 25328 KB Output is correct
88 Correct 82 ms 25376 KB Output is correct
89 Correct 80 ms 25328 KB Output is correct
90 Correct 81 ms 25352 KB Output is correct