답안 #678640

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
678640 2023-01-06T09:09:23 Z Hiennoob123 Dango Maker (JOI18_dango_maker) C++14
100 / 100
312 ms 170784 KB
#include<bits/stdc++.h>
#define ll long long
#define ld long double
#define cd complex<ld>
#define pll pair<ll,ll>
#define pii pair<int,int>
#define pld pair<ld,ld>
#define pb push_back
#define mp make_pair
#define fi first
#define se second
using namespace std;
ll n, m;
char c[3005][3005];
ll dp[2][3005][3005];
ll ans[3005][3005];
bool chk[2][3005][3005];
//vector<pair<ll,pll>> T[2][3005][3005];
void solve()
{
    cin >> n >> m;
    for(int i = 1; i<= n; i++)
    {
        for(int j = 1; j<= m; j++) cin >> c[i][j];
    }
    for(int i = 1 ;i<= n; i++)
    {
        for(int j = 3; j<= m; j++)
        {
            if(c[i][j-1]=='G'&&c[i][j]=='W'&&c[i][j-1]!=c[i][j-2]&&c[i][j-2]!=c[i][j]&&c[i][j]!=c[i][j-1]) chk[0][i][j] = 1;
        }
    }
    for(int i = 3 ;i<= n; i++)
    {
        for(int j = 1; j<= m; j++)
        {
            if(c[i-1][j]=='G'&&c[i][j]=='W'&&c[i-1][j]!=c[i-2][j]&&c[i][j]!=c[i-2][j]&&c[i][j]!=c[i-1][j]) chk[1][i][j] = 1;
        }
    }
    for(int i = 1; i<= n; i++)
    {
        for(int j = 1; j<= m; j++)
        {
            dp[1][i][j] = chk[1][i][j]+dp[1][i-1][j+1];
            if(i-3>=0) dp[1][i][j] = max(dp[1][i][j], dp[0][i-3][j+3]+chk[1][i][j]);
            dp[0][i][j] = max(dp[0][i-1][j+1]+chk[0][i][j],dp[1][i][j]);
            //cout << i << " " << j << " " << dp[0][i][j] << " " << dp[1][i][j] << " " << chk[0][i][j] << " " << chk[1][i][j] << " " << dp[0][i-1][j+1]<< "\n";
        }
    }
    ll ans = 0;
    for(int i = 1; i<= n; i++)
    {
        for(int j = 1 ; j<= m; j++)
        {
            if(j==1||i==n)
            {
                ans += dp[0][i][j];
            }
            //cout << i << " " << j << " " << dp[0][i][j] << " " << dp[1][i][j] << " " << chk[0][i][j] << " " << chk[1][i][j] << " " << dp[0][i-1][j+1]<< "\n";
        }
    }
    cout << ans;
}
signed main()
{
    //freopen("IN.txt","r",stdin);
    //freopen("OUT.txt","w",stdout);
    ios_base::sync_with_stdio(NULL) ; cin.tie(nullptr) ; cout.tie(nullptr);
    ll t = 1;
    //cin >> t;
    while(t--)
    {
        solve();
        cout << "\n";
    }
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 340 KB Output is correct
2 Correct 0 ms 340 KB Output is correct
3 Correct 0 ms 340 KB Output is correct
4 Correct 0 ms 340 KB Output is correct
5 Correct 0 ms 340 KB Output is correct
6 Correct 0 ms 340 KB Output is correct
7 Correct 0 ms 340 KB Output is correct
8 Correct 0 ms 340 KB Output is correct
9 Correct 0 ms 340 KB Output is correct
10 Correct 1 ms 340 KB Output is correct
11 Correct 1 ms 340 KB Output is correct
12 Correct 1 ms 340 KB Output is correct
13 Correct 0 ms 340 KB Output is correct
14 Correct 1 ms 340 KB Output is correct
15 Correct 1 ms 340 KB Output is correct
16 Correct 0 ms 340 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 340 KB Output is correct
2 Correct 0 ms 340 KB Output is correct
3 Correct 0 ms 340 KB Output is correct
4 Correct 0 ms 340 KB Output is correct
5 Correct 0 ms 340 KB Output is correct
6 Correct 0 ms 340 KB Output is correct
7 Correct 0 ms 340 KB Output is correct
8 Correct 0 ms 340 KB Output is correct
9 Correct 0 ms 340 KB Output is correct
10 Correct 1 ms 340 KB Output is correct
11 Correct 1 ms 340 KB Output is correct
12 Correct 1 ms 340 KB Output is correct
13 Correct 0 ms 340 KB Output is correct
14 Correct 1 ms 340 KB Output is correct
15 Correct 1 ms 340 KB Output is correct
16 Correct 0 ms 340 KB Output is correct
17 Correct 1 ms 340 KB Output is correct
18 Correct 0 ms 340 KB Output is correct
19 Correct 0 ms 340 KB Output is correct
20 Correct 0 ms 468 KB Output is correct
21 Correct 1 ms 468 KB Output is correct
22 Correct 0 ms 468 KB Output is correct
23 Correct 1 ms 468 KB Output is correct
24 Correct 1 ms 468 KB Output is correct
25 Correct 1 ms 340 KB Output is correct
26 Correct 0 ms 340 KB Output is correct
27 Correct 1 ms 468 KB Output is correct
28 Correct 0 ms 468 KB Output is correct
29 Correct 1 ms 460 KB Output is correct
30 Correct 0 ms 456 KB Output is correct
31 Correct 1 ms 468 KB Output is correct
32 Correct 1 ms 468 KB Output is correct
33 Correct 1 ms 468 KB Output is correct
34 Correct 1 ms 468 KB Output is correct
35 Correct 1 ms 468 KB Output is correct
36 Correct 1 ms 468 KB Output is correct
37 Correct 1 ms 468 KB Output is correct
38 Correct 0 ms 468 KB Output is correct
39 Correct 0 ms 468 KB Output is correct
40 Correct 0 ms 468 KB Output is correct
41 Correct 1 ms 468 KB Output is correct
42 Correct 1 ms 468 KB Output is correct
43 Correct 0 ms 468 KB Output is correct
44 Correct 1 ms 468 KB Output is correct
45 Correct 1 ms 456 KB Output is correct
46 Correct 1 ms 468 KB Output is correct
47 Correct 1 ms 456 KB Output is correct
48 Correct 1 ms 468 KB Output is correct
49 Correct 1 ms 468 KB Output is correct
50 Correct 1 ms 468 KB Output is correct
51 Correct 1 ms 468 KB Output is correct
52 Correct 1 ms 468 KB Output is correct
53 Correct 1 ms 468 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 340 KB Output is correct
2 Correct 0 ms 340 KB Output is correct
3 Correct 0 ms 340 KB Output is correct
4 Correct 0 ms 340 KB Output is correct
5 Correct 0 ms 340 KB Output is correct
6 Correct 0 ms 340 KB Output is correct
7 Correct 0 ms 340 KB Output is correct
8 Correct 0 ms 340 KB Output is correct
9 Correct 0 ms 340 KB Output is correct
10 Correct 1 ms 340 KB Output is correct
11 Correct 1 ms 340 KB Output is correct
12 Correct 1 ms 340 KB Output is correct
13 Correct 0 ms 340 KB Output is correct
14 Correct 1 ms 340 KB Output is correct
15 Correct 1 ms 340 KB Output is correct
16 Correct 0 ms 340 KB Output is correct
17 Correct 1 ms 340 KB Output is correct
18 Correct 0 ms 340 KB Output is correct
19 Correct 0 ms 340 KB Output is correct
20 Correct 0 ms 468 KB Output is correct
21 Correct 1 ms 468 KB Output is correct
22 Correct 0 ms 468 KB Output is correct
23 Correct 1 ms 468 KB Output is correct
24 Correct 1 ms 468 KB Output is correct
25 Correct 1 ms 340 KB Output is correct
26 Correct 0 ms 340 KB Output is correct
27 Correct 1 ms 468 KB Output is correct
28 Correct 0 ms 468 KB Output is correct
29 Correct 1 ms 460 KB Output is correct
30 Correct 0 ms 456 KB Output is correct
31 Correct 1 ms 468 KB Output is correct
32 Correct 1 ms 468 KB Output is correct
33 Correct 1 ms 468 KB Output is correct
34 Correct 1 ms 468 KB Output is correct
35 Correct 1 ms 468 KB Output is correct
36 Correct 1 ms 468 KB Output is correct
37 Correct 1 ms 468 KB Output is correct
38 Correct 0 ms 468 KB Output is correct
39 Correct 0 ms 468 KB Output is correct
40 Correct 0 ms 468 KB Output is correct
41 Correct 1 ms 468 KB Output is correct
42 Correct 1 ms 468 KB Output is correct
43 Correct 0 ms 468 KB Output is correct
44 Correct 1 ms 468 KB Output is correct
45 Correct 1 ms 456 KB Output is correct
46 Correct 1 ms 468 KB Output is correct
47 Correct 1 ms 456 KB Output is correct
48 Correct 1 ms 468 KB Output is correct
49 Correct 1 ms 468 KB Output is correct
50 Correct 1 ms 468 KB Output is correct
51 Correct 1 ms 468 KB Output is correct
52 Correct 1 ms 468 KB Output is correct
53 Correct 1 ms 468 KB Output is correct
54 Correct 1 ms 340 KB Output is correct
55 Correct 15 ms 33864 KB Output is correct
56 Correct 1 ms 596 KB Output is correct
57 Correct 12 ms 30900 KB Output is correct
58 Correct 38 ms 33728 KB Output is correct
59 Correct 292 ms 170732 KB Output is correct
60 Correct 285 ms 170748 KB Output is correct
61 Correct 312 ms 170740 KB Output is correct
62 Correct 1 ms 468 KB Output is correct
63 Correct 283 ms 170784 KB Output is correct
64 Correct 225 ms 170656 KB Output is correct
65 Correct 246 ms 170668 KB Output is correct
66 Correct 204 ms 170692 KB Output is correct
67 Correct 214 ms 160108 KB Output is correct
68 Correct 202 ms 160140 KB Output is correct
69 Correct 216 ms 166524 KB Output is correct
70 Correct 30 ms 33740 KB Output is correct
71 Correct 32 ms 33784 KB Output is correct
72 Correct 33 ms 33740 KB Output is correct
73 Correct 34 ms 33740 KB Output is correct
74 Correct 34 ms 33820 KB Output is correct
75 Correct 34 ms 33728 KB Output is correct
76 Correct 32 ms 33796 KB Output is correct
77 Correct 31 ms 33780 KB Output is correct
78 Correct 40 ms 33740 KB Output is correct
79 Correct 33 ms 33776 KB Output is correct
80 Correct 32 ms 33820 KB Output is correct
81 Correct 31 ms 33744 KB Output is correct
82 Correct 32 ms 33752 KB Output is correct
83 Correct 35 ms 33740 KB Output is correct
84 Correct 34 ms 33780 KB Output is correct
85 Correct 31 ms 33752 KB Output is correct
86 Correct 31 ms 33760 KB Output is correct
87 Correct 36 ms 33744 KB Output is correct
88 Correct 29 ms 33720 KB Output is correct
89 Correct 30 ms 33736 KB Output is correct
90 Correct 30 ms 33760 KB Output is correct