Submission #747715

# Submission time Handle Problem Language Result Execution time Memory
747715 2023-05-24T14:36:42 Z Sami_Massah Dango Maker (JOI18_dango_maker) C++17
100 / 100
671 ms 19468 KB
#include <bits/stdc++.h>
using namespace std;


const long long maxn = 3000 + 12 ;
long long n, m, ans, dp[maxn][4][4];
string s[maxn];
vector <int> nums;
bool val(int a, int b){
    if(a < 0 || a >= n)
        return 0;
    if(b < 0 || b >= m)
        return 0;
    return 1;
}
int get_max(){
  //  for(int i: nums)
    //    cout << i << ' ';
    //cout << endl;
    for(int i = 0; i <= nums.size(); i++)
        for(int j = 0; j < 4; j++)
            for(int c = 0; c < 4; c++)
                dp[i][j][c] = 0;
    for(int i = 3; i < nums.size(); i++){
        for(int j = 0; j < 4; j++)
            for(int c = 0; c < 4; c++){

                if(j & 1)
                    dp[i][c][j] = max(dp[i][c][j], dp[i - 2][nums[i - 2] & 1][nums[i - 3] & 1] + 1 + (c > 0));
                if(j & 2)
                    dp[i][c][j] = max(dp[i][c][j], dp[i - 2][nums[i - 2]][nums[i - 3]] + 1 + ((c & 2) > 0));

                if(c & 2)
                    dp[i][c][j] = max(dp[i][c][j], dp[i - 2][nums[i - 2]][nums[i - 3]] + 1);
                if(c & 1)
                    dp[i][c][j] = max(dp[i][c][j], dp[i - 2][nums[i - 2] & 1][nums[i - 3]] + 1);
                dp[i][c][j] = max(dp[i][c][j], dp[i - 2][nums[i - 2]][nums[i - 3]]);

        }
    //    cout << i - 2 << ' ' << dp[i][nums[i]][nums[i - 1]] << endl;

    }
    int f = nums[nums.size() - 1];
    int s = nums[nums.size() - 2];
    return dp[nums.size() - 1][f][s];


}
int main(){
    ios_base::sync_with_stdio(false), cin.tie(0);

    cin >> n >> m;
    for(int i = 0; i < n; i++)
        cin >> s[i];

    for(int sum = 0; sum <= n + m - 2; sum++){
        nums.push_back(0);
        nums.push_back(0);
        nums.push_back(0);
        for(int j = 0; j < m; j++){
            int i = sum - j;
            if(i < 0 || i >= n)
                continue;
            nums.push_back(0);
            int a = i, b = j;
            if(s[i][j] == 'R' && val(a + 1, b) && s[a + 1][b] == 'G' && val(a + 2, b) && s[a + 2][b] == 'W')
                nums.back() += 1;
            if(s[i][j] == 'R' && val(a, b + 1) && s[a][b + 1] == 'G' && val(a, b + 2) && s[a][b + 2] == 'W')
                nums.back() += 2;

        }
        int x = get_max();
        ans += x;
       // cout << sum << ' ' << x << endl;
        nums.clear();



    }
    cout << ans << endl;


}

Compilation message

dango_maker.cpp: In function 'int get_max()':
dango_maker.cpp:20:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   20 |     for(int i = 0; i <= nums.size(); i++)
      |                    ~~^~~~~~~~~~~~~~
dango_maker.cpp:24:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   24 |     for(int i = 3; i < nums.size(); i++){
      |                    ~~^~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 0 ms 340 KB Output is correct
2 Correct 0 ms 340 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 0 ms 340 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 0 ms 340 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 1 ms 340 KB Output is correct
10 Correct 1 ms 340 KB Output is correct
11 Correct 0 ms 340 KB Output is correct
12 Correct 1 ms 340 KB Output is correct
13 Correct 1 ms 340 KB Output is correct
14 Correct 0 ms 340 KB Output is correct
15 Correct 0 ms 340 KB Output is correct
16 Correct 1 ms 340 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 340 KB Output is correct
2 Correct 0 ms 340 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 0 ms 340 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 0 ms 340 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 1 ms 340 KB Output is correct
10 Correct 1 ms 340 KB Output is correct
11 Correct 0 ms 340 KB Output is correct
12 Correct 1 ms 340 KB Output is correct
13 Correct 1 ms 340 KB Output is correct
14 Correct 0 ms 340 KB Output is correct
15 Correct 0 ms 340 KB Output is correct
16 Correct 1 ms 340 KB Output is correct
17 Correct 1 ms 340 KB Output is correct
18 Correct 1 ms 420 KB Output is correct
19 Correct 1 ms 340 KB Output is correct
20 Correct 0 ms 340 KB Output is correct
21 Correct 1 ms 340 KB Output is correct
22 Correct 1 ms 340 KB Output is correct
23 Correct 1 ms 340 KB Output is correct
24 Correct 1 ms 340 KB Output is correct
25 Correct 1 ms 340 KB Output is correct
26 Correct 1 ms 344 KB Output is correct
27 Correct 1 ms 340 KB Output is correct
28 Correct 1 ms 340 KB Output is correct
29 Correct 1 ms 340 KB Output is correct
30 Correct 1 ms 340 KB Output is correct
31 Correct 1 ms 340 KB Output is correct
32 Correct 1 ms 420 KB Output is correct
33 Correct 0 ms 420 KB Output is correct
34 Correct 1 ms 340 KB Output is correct
35 Correct 1 ms 340 KB Output is correct
36 Correct 0 ms 340 KB Output is correct
37 Correct 1 ms 468 KB Output is correct
38 Correct 1 ms 340 KB Output is correct
39 Correct 1 ms 340 KB Output is correct
40 Correct 1 ms 340 KB Output is correct
41 Correct 1 ms 340 KB Output is correct
42 Correct 1 ms 424 KB Output is correct
43 Correct 1 ms 340 KB Output is correct
44 Correct 0 ms 340 KB Output is correct
45 Correct 1 ms 340 KB Output is correct
46 Correct 0 ms 428 KB Output is correct
47 Correct 1 ms 360 KB Output is correct
48 Correct 1 ms 340 KB Output is correct
49 Correct 1 ms 424 KB Output is correct
50 Correct 1 ms 340 KB Output is correct
51 Correct 1 ms 340 KB Output is correct
52 Correct 1 ms 340 KB Output is correct
53 Correct 1 ms 424 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 340 KB Output is correct
2 Correct 0 ms 340 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 0 ms 340 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 0 ms 340 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 1 ms 340 KB Output is correct
10 Correct 1 ms 340 KB Output is correct
11 Correct 0 ms 340 KB Output is correct
12 Correct 1 ms 340 KB Output is correct
13 Correct 1 ms 340 KB Output is correct
14 Correct 0 ms 340 KB Output is correct
15 Correct 0 ms 340 KB Output is correct
16 Correct 1 ms 340 KB Output is correct
17 Correct 1 ms 340 KB Output is correct
18 Correct 1 ms 420 KB Output is correct
19 Correct 1 ms 340 KB Output is correct
20 Correct 0 ms 340 KB Output is correct
21 Correct 1 ms 340 KB Output is correct
22 Correct 1 ms 340 KB Output is correct
23 Correct 1 ms 340 KB Output is correct
24 Correct 1 ms 340 KB Output is correct
25 Correct 1 ms 340 KB Output is correct
26 Correct 1 ms 344 KB Output is correct
27 Correct 1 ms 340 KB Output is correct
28 Correct 1 ms 340 KB Output is correct
29 Correct 1 ms 340 KB Output is correct
30 Correct 1 ms 340 KB Output is correct
31 Correct 1 ms 340 KB Output is correct
32 Correct 1 ms 420 KB Output is correct
33 Correct 0 ms 420 KB Output is correct
34 Correct 1 ms 340 KB Output is correct
35 Correct 1 ms 340 KB Output is correct
36 Correct 0 ms 340 KB Output is correct
37 Correct 1 ms 468 KB Output is correct
38 Correct 1 ms 340 KB Output is correct
39 Correct 1 ms 340 KB Output is correct
40 Correct 1 ms 340 KB Output is correct
41 Correct 1 ms 340 KB Output is correct
42 Correct 1 ms 424 KB Output is correct
43 Correct 1 ms 340 KB Output is correct
44 Correct 0 ms 340 KB Output is correct
45 Correct 1 ms 340 KB Output is correct
46 Correct 0 ms 428 KB Output is correct
47 Correct 1 ms 360 KB Output is correct
48 Correct 1 ms 340 KB Output is correct
49 Correct 1 ms 424 KB Output is correct
50 Correct 1 ms 340 KB Output is correct
51 Correct 1 ms 340 KB Output is correct
52 Correct 1 ms 340 KB Output is correct
53 Correct 1 ms 424 KB Output is correct
54 Correct 8 ms 436 KB Output is correct
55 Correct 1 ms 340 KB Output is correct
56 Correct 9 ms 340 KB Output is correct
57 Correct 2 ms 340 KB Output is correct
58 Correct 72 ms 2580 KB Output is correct
59 Correct 671 ms 19380 KB Output is correct
60 Correct 652 ms 19364 KB Output is correct
61 Correct 649 ms 19448 KB Output is correct
62 Correct 7 ms 340 KB Output is correct
63 Correct 621 ms 18752 KB Output is correct
64 Correct 620 ms 19348 KB Output is correct
65 Correct 601 ms 19260 KB Output is correct
66 Correct 613 ms 19368 KB Output is correct
67 Correct 599 ms 19468 KB Output is correct
68 Correct 593 ms 19400 KB Output is correct
69 Correct 600 ms 19404 KB Output is correct
70 Correct 68 ms 2484 KB Output is correct
71 Correct 65 ms 2476 KB Output is correct
72 Correct 64 ms 2584 KB Output is correct
73 Correct 67 ms 2588 KB Output is correct
74 Correct 65 ms 2572 KB Output is correct
75 Correct 68 ms 2592 KB Output is correct
76 Correct 67 ms 2540 KB Output is correct
77 Correct 67 ms 2580 KB Output is correct
78 Correct 65 ms 2604 KB Output is correct
79 Correct 65 ms 2584 KB Output is correct
80 Correct 67 ms 2616 KB Output is correct
81 Correct 66 ms 2536 KB Output is correct
82 Correct 73 ms 2584 KB Output is correct
83 Correct 70 ms 2596 KB Output is correct
84 Correct 65 ms 2492 KB Output is correct
85 Correct 65 ms 2584 KB Output is correct
86 Correct 64 ms 2540 KB Output is correct
87 Correct 67 ms 2588 KB Output is correct
88 Correct 65 ms 2576 KB Output is correct
89 Correct 69 ms 2580 KB Output is correct
90 Correct 64 ms 2568 KB Output is correct