#include <bits/stdc++.h>
#define NMAX 2005
#define pb push_back
#define eb emplace_back
#define MOD 100003
#define nl '\n'
#define LLONG_MAX 9223372036854775807
#define pii pair<int,int>
#define tpl tuple<int,int,int>
//#pragma GCC optimize("O3")
#define INF 2147483647
using namespace std;
ifstream fin("aib.in");
ofstream fout("aib.out");
/*
*
*
================DEMONSTRATION===================
5 5
RGRGW
GRRGW
WGGWR
RWRGW
RGWGW
=====================END========================
*/
int n,m;
int mat[3005][3005];
vector<pii>indR;
int rgw[]={0,1,2,3};
int hor(int i,int j)
{
return (mat[i][j-1]==1 && mat[i][j]==2 && mat[i][j+1]==3);
}
int ver(int i,int j)
{
return (mat[i-1][j]==1 && mat[i][j]==2 && mat[i+1][j]==3);
}
int dp[3][3005][3005];
signed main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cin>>n>>m;
for(int i=1;i<=n;++i)
{
for(int j=1;j<=m;++j)
{
char x;
cin>>x;
if(x=='R')
{
indR.pb({i,j});
mat[i][j]=1;
}
else if(x=='G')
{
mat[i][j]=2;
}
else
mat[i][j]=3;
}
}
for(int i=1;i<=n;++i)
{
for(int j=1;j<=m;++j)
{
dp[0][i][j]=max({dp[0][i-1][j+1],dp[1][i-1][j+1],dp[2][i-1][j+1]});
dp[1][i][j]=max(dp[0][i-1][j+1],dp[1][i-1][j+1])+hor(i,j);
dp[2][i][j]=max(dp[0][i-1][j+1],dp[2][i-1][j+1])+ver(i,j);
}
}
int ans=0;
for(int i=1;i<=n;++i)
{
ans+=max({dp[0][i][1],dp[1][i][1],dp[2][i][1]});
}
for(int i=2;i<=m;++i)
{
ans+=max({dp[0][n][i],dp[1][n][i],dp[2][n][i]});
}
cout<<ans;
return 0;
}
Compilation message
dango_maker.cpp:7: warning: "LLONG_MAX" redefined
7 | #define LLONG_MAX 9223372036854775807
|
In file included from /usr/lib/gcc/x86_64-linux-gnu/10/include/limits.h:195,
from /usr/lib/gcc/x86_64-linux-gnu/10/include/syslimits.h:7,
from /usr/lib/gcc/x86_64-linux-gnu/10/include/limits.h:34,
from /usr/include/c++/10/climits:42,
from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:39,
from dango_maker.cpp:1:
/usr/include/limits.h:135: note: this is the location of the previous definition
135 | # define LLONG_MAX __LONG_LONG_MAX__
|
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
2396 KB |
Output is correct |
2 |
Correct |
1 ms |
2396 KB |
Output is correct |
3 |
Correct |
1 ms |
2396 KB |
Output is correct |
4 |
Correct |
1 ms |
2392 KB |
Output is correct |
5 |
Correct |
0 ms |
2396 KB |
Output is correct |
6 |
Correct |
1 ms |
2396 KB |
Output is correct |
7 |
Correct |
1 ms |
2396 KB |
Output is correct |
8 |
Correct |
1 ms |
2396 KB |
Output is correct |
9 |
Correct |
0 ms |
2396 KB |
Output is correct |
10 |
Correct |
1 ms |
2396 KB |
Output is correct |
11 |
Correct |
1 ms |
2396 KB |
Output is correct |
12 |
Correct |
1 ms |
2396 KB |
Output is correct |
13 |
Correct |
1 ms |
2396 KB |
Output is correct |
14 |
Correct |
1 ms |
2396 KB |
Output is correct |
15 |
Correct |
1 ms |
2396 KB |
Output is correct |
16 |
Correct |
1 ms |
2396 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
2396 KB |
Output is correct |
2 |
Correct |
1 ms |
2396 KB |
Output is correct |
3 |
Correct |
1 ms |
2396 KB |
Output is correct |
4 |
Correct |
1 ms |
2392 KB |
Output is correct |
5 |
Correct |
0 ms |
2396 KB |
Output is correct |
6 |
Correct |
1 ms |
2396 KB |
Output is correct |
7 |
Correct |
1 ms |
2396 KB |
Output is correct |
8 |
Correct |
1 ms |
2396 KB |
Output is correct |
9 |
Correct |
0 ms |
2396 KB |
Output is correct |
10 |
Correct |
1 ms |
2396 KB |
Output is correct |
11 |
Correct |
1 ms |
2396 KB |
Output is correct |
12 |
Correct |
1 ms |
2396 KB |
Output is correct |
13 |
Correct |
1 ms |
2396 KB |
Output is correct |
14 |
Correct |
1 ms |
2396 KB |
Output is correct |
15 |
Correct |
1 ms |
2396 KB |
Output is correct |
16 |
Correct |
1 ms |
2396 KB |
Output is correct |
17 |
Correct |
1 ms |
2392 KB |
Output is correct |
18 |
Correct |
1 ms |
2396 KB |
Output is correct |
19 |
Correct |
1 ms |
2620 KB |
Output is correct |
20 |
Correct |
1 ms |
2652 KB |
Output is correct |
21 |
Correct |
1 ms |
2408 KB |
Output is correct |
22 |
Correct |
1 ms |
2652 KB |
Output is correct |
23 |
Correct |
0 ms |
2652 KB |
Output is correct |
24 |
Correct |
1 ms |
2648 KB |
Output is correct |
25 |
Correct |
1 ms |
2648 KB |
Output is correct |
26 |
Correct |
0 ms |
2396 KB |
Output is correct |
27 |
Correct |
0 ms |
2652 KB |
Output is correct |
28 |
Correct |
1 ms |
2652 KB |
Output is correct |
29 |
Correct |
0 ms |
2652 KB |
Output is correct |
30 |
Correct |
1 ms |
2648 KB |
Output is correct |
31 |
Correct |
1 ms |
2652 KB |
Output is correct |
32 |
Correct |
1 ms |
2652 KB |
Output is correct |
33 |
Correct |
0 ms |
2652 KB |
Output is correct |
34 |
Correct |
1 ms |
2648 KB |
Output is correct |
35 |
Correct |
0 ms |
2652 KB |
Output is correct |
36 |
Correct |
1 ms |
2648 KB |
Output is correct |
37 |
Correct |
1 ms |
2652 KB |
Output is correct |
38 |
Correct |
1 ms |
2652 KB |
Output is correct |
39 |
Correct |
1 ms |
2652 KB |
Output is correct |
40 |
Correct |
0 ms |
2652 KB |
Output is correct |
41 |
Correct |
1 ms |
2652 KB |
Output is correct |
42 |
Correct |
1 ms |
2652 KB |
Output is correct |
43 |
Correct |
1 ms |
2652 KB |
Output is correct |
44 |
Correct |
1 ms |
2652 KB |
Output is correct |
45 |
Correct |
1 ms |
2652 KB |
Output is correct |
46 |
Correct |
1 ms |
2652 KB |
Output is correct |
47 |
Correct |
1 ms |
2652 KB |
Output is correct |
48 |
Correct |
1 ms |
2648 KB |
Output is correct |
49 |
Correct |
1 ms |
2652 KB |
Output is correct |
50 |
Correct |
0 ms |
2652 KB |
Output is correct |
51 |
Correct |
1 ms |
2652 KB |
Output is correct |
52 |
Correct |
1 ms |
2652 KB |
Output is correct |
53 |
Correct |
1 ms |
2652 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
2396 KB |
Output is correct |
2 |
Correct |
1 ms |
2396 KB |
Output is correct |
3 |
Correct |
1 ms |
2396 KB |
Output is correct |
4 |
Correct |
1 ms |
2392 KB |
Output is correct |
5 |
Correct |
0 ms |
2396 KB |
Output is correct |
6 |
Correct |
1 ms |
2396 KB |
Output is correct |
7 |
Correct |
1 ms |
2396 KB |
Output is correct |
8 |
Correct |
1 ms |
2396 KB |
Output is correct |
9 |
Correct |
0 ms |
2396 KB |
Output is correct |
10 |
Correct |
1 ms |
2396 KB |
Output is correct |
11 |
Correct |
1 ms |
2396 KB |
Output is correct |
12 |
Correct |
1 ms |
2396 KB |
Output is correct |
13 |
Correct |
1 ms |
2396 KB |
Output is correct |
14 |
Correct |
1 ms |
2396 KB |
Output is correct |
15 |
Correct |
1 ms |
2396 KB |
Output is correct |
16 |
Correct |
1 ms |
2396 KB |
Output is correct |
17 |
Correct |
1 ms |
2392 KB |
Output is correct |
18 |
Correct |
1 ms |
2396 KB |
Output is correct |
19 |
Correct |
1 ms |
2620 KB |
Output is correct |
20 |
Correct |
1 ms |
2652 KB |
Output is correct |
21 |
Correct |
1 ms |
2408 KB |
Output is correct |
22 |
Correct |
1 ms |
2652 KB |
Output is correct |
23 |
Correct |
0 ms |
2652 KB |
Output is correct |
24 |
Correct |
1 ms |
2648 KB |
Output is correct |
25 |
Correct |
1 ms |
2648 KB |
Output is correct |
26 |
Correct |
0 ms |
2396 KB |
Output is correct |
27 |
Correct |
0 ms |
2652 KB |
Output is correct |
28 |
Correct |
1 ms |
2652 KB |
Output is correct |
29 |
Correct |
0 ms |
2652 KB |
Output is correct |
30 |
Correct |
1 ms |
2648 KB |
Output is correct |
31 |
Correct |
1 ms |
2652 KB |
Output is correct |
32 |
Correct |
1 ms |
2652 KB |
Output is correct |
33 |
Correct |
0 ms |
2652 KB |
Output is correct |
34 |
Correct |
1 ms |
2648 KB |
Output is correct |
35 |
Correct |
0 ms |
2652 KB |
Output is correct |
36 |
Correct |
1 ms |
2648 KB |
Output is correct |
37 |
Correct |
1 ms |
2652 KB |
Output is correct |
38 |
Correct |
1 ms |
2652 KB |
Output is correct |
39 |
Correct |
1 ms |
2652 KB |
Output is correct |
40 |
Correct |
0 ms |
2652 KB |
Output is correct |
41 |
Correct |
1 ms |
2652 KB |
Output is correct |
42 |
Correct |
1 ms |
2652 KB |
Output is correct |
43 |
Correct |
1 ms |
2652 KB |
Output is correct |
44 |
Correct |
1 ms |
2652 KB |
Output is correct |
45 |
Correct |
1 ms |
2652 KB |
Output is correct |
46 |
Correct |
1 ms |
2652 KB |
Output is correct |
47 |
Correct |
1 ms |
2652 KB |
Output is correct |
48 |
Correct |
1 ms |
2648 KB |
Output is correct |
49 |
Correct |
1 ms |
2652 KB |
Output is correct |
50 |
Correct |
0 ms |
2652 KB |
Output is correct |
51 |
Correct |
1 ms |
2652 KB |
Output is correct |
52 |
Correct |
1 ms |
2652 KB |
Output is correct |
53 |
Correct |
1 ms |
2652 KB |
Output is correct |
54 |
Correct |
1 ms |
2396 KB |
Output is correct |
55 |
Correct |
18 ms |
67520 KB |
Output is correct |
56 |
Correct |
1 ms |
2652 KB |
Output is correct |
57 |
Correct |
11 ms |
52916 KB |
Output is correct |
58 |
Correct |
37 ms |
45776 KB |
Output is correct |
59 |
Correct |
300 ms |
173904 KB |
Output is correct |
60 |
Correct |
295 ms |
173984 KB |
Output is correct |
61 |
Correct |
312 ms |
173984 KB |
Output is correct |
62 |
Correct |
1 ms |
2648 KB |
Output is correct |
63 |
Correct |
290 ms |
172964 KB |
Output is correct |
64 |
Correct |
164 ms |
174036 KB |
Output is correct |
65 |
Correct |
160 ms |
173976 KB |
Output is correct |
66 |
Correct |
152 ms |
173932 KB |
Output is correct |
67 |
Correct |
162 ms |
174240 KB |
Output is correct |
68 |
Correct |
165 ms |
173876 KB |
Output is correct |
69 |
Correct |
161 ms |
173844 KB |
Output is correct |
70 |
Correct |
21 ms |
46284 KB |
Output is correct |
71 |
Correct |
22 ms |
47116 KB |
Output is correct |
72 |
Correct |
21 ms |
46284 KB |
Output is correct |
73 |
Correct |
22 ms |
45512 KB |
Output is correct |
74 |
Correct |
21 ms |
47088 KB |
Output is correct |
75 |
Correct |
22 ms |
46544 KB |
Output is correct |
76 |
Correct |
20 ms |
46284 KB |
Output is correct |
77 |
Correct |
22 ms |
47056 KB |
Output is correct |
78 |
Correct |
21 ms |
47720 KB |
Output is correct |
79 |
Correct |
21 ms |
47028 KB |
Output is correct |
80 |
Correct |
23 ms |
45508 KB |
Output is correct |
81 |
Correct |
23 ms |
47812 KB |
Output is correct |
82 |
Correct |
22 ms |
45512 KB |
Output is correct |
83 |
Correct |
26 ms |
46792 KB |
Output is correct |
84 |
Correct |
21 ms |
45520 KB |
Output is correct |
85 |
Correct |
29 ms |
46792 KB |
Output is correct |
86 |
Correct |
23 ms |
46544 KB |
Output is correct |
87 |
Correct |
24 ms |
46952 KB |
Output is correct |
88 |
Correct |
24 ms |
46288 KB |
Output is correct |
89 |
Correct |
21 ms |
45512 KB |
Output is correct |
90 |
Correct |
21 ms |
45764 KB |
Output is correct |