답안 #914956

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
914956 2024-01-23T02:48:45 Z HorizonWest Dango Maker (JOI18_dango_maker) C++17
100 / 100
1489 ms 18800 KB
#include <bits/stdc++.h>
using namespace std;

#define endl '\n'
#define db double
#define ll __int128
#define int long long
#define pb push_back
#define fs first
#define sd second
#define Mod long(1e9 + 7)
#define all(x) x.begin(), x.end()
#define unvisited long(-1)
#define Eps double(1e-9)
#define _for(i, n) for(int i = 0; i < (n); i++)
#define dbg(x) cout << #x ": " << x << endl;

const int Max = (1LL << 32), Inf = 1e9 + 7;

void print(bool x) { cout << (x ? "YES" : "NO") << endl; }

string tostring (ll x)
{
    string ans = "";
    while(x > 0)
    {
        ans += (x % 10 + '0');
        x /= 10;
    }
    reverse(all(ans));
    return ans;
}

void solve()
{
    int n, m, ans = 0; cin >> n >> m; 
    vector <vector<char>> v(n, vector <char> (m, 0));
    for(auto& u : v) for(auto& t : u) cin >> t;

    for(int i = 1; i < n+m; i++)
    {
        vector <vector<int>> dp(n+7, vector <int> (3, 0));
        vector <vector<char>> s(n+7, vector <char> (3, '.'));

        for(int j = 0; j < n; j++)
        {
            for(int k = 0; k < 3; k++)
            {
                int x = j, y = i - j + k - 1;
                if(x < 0 || x > n - 1 || y < 0 || y > m - 1) continue;
                s[j][k] = v[x][y];
            }
        }

        for(int j = 0; j <= n+3; j++)
        {
            for(int k = 0; k < 3; k++)
            {
                dp[j+1][0] = max(dp[j+1][0], dp[j][k]);
                if(s[j][0] == 'R' && s[j][1] == 'G' && s[j][2] == 'W')
                    dp[j+1][1] = max(dp[j][0], dp[j][1]) + 1;
                if(j != 0)
                {
                    if(s[j-1][0] == 'R' && s[j][1] == 'G' && s[j+1][2] == 'W')
                        dp[j+1][2] = max(dp[j][2], dp[j][0]) + 1; 
                }
            }
        }
      
        ans += dp[n+3][0];
    }

    cout << ans << endl;
}

int32_t main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);

    int Q = 1; //cin >> Q;

    while (Q--)
    {
        solve();
    }

    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 452 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 1 ms 344 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 1 ms 348 KB Output is correct
16 Correct 1 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 452 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 1 ms 344 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 1 ms 348 KB Output is correct
16 Correct 1 ms 348 KB Output is correct
17 Correct 1 ms 348 KB Output is correct
18 Correct 1 ms 344 KB Output is correct
19 Correct 0 ms 348 KB Output is correct
20 Correct 0 ms 348 KB Output is correct
21 Correct 0 ms 460 KB Output is correct
22 Correct 0 ms 348 KB Output is correct
23 Correct 0 ms 348 KB Output is correct
24 Correct 1 ms 348 KB Output is correct
25 Correct 0 ms 456 KB Output is correct
26 Correct 0 ms 348 KB Output is correct
27 Correct 0 ms 600 KB Output is correct
28 Correct 1 ms 348 KB Output is correct
29 Correct 0 ms 348 KB Output is correct
30 Correct 0 ms 456 KB Output is correct
31 Correct 1 ms 348 KB Output is correct
32 Correct 0 ms 348 KB Output is correct
33 Correct 0 ms 344 KB Output is correct
34 Correct 0 ms 348 KB Output is correct
35 Correct 0 ms 348 KB Output is correct
36 Correct 1 ms 348 KB Output is correct
37 Correct 0 ms 348 KB Output is correct
38 Correct 0 ms 460 KB Output is correct
39 Correct 1 ms 348 KB Output is correct
40 Correct 1 ms 348 KB Output is correct
41 Correct 1 ms 348 KB Output is correct
42 Correct 1 ms 348 KB Output is correct
43 Correct 0 ms 348 KB Output is correct
44 Correct 0 ms 348 KB Output is correct
45 Correct 0 ms 420 KB Output is correct
46 Correct 0 ms 348 KB Output is correct
47 Correct 0 ms 348 KB Output is correct
48 Correct 0 ms 348 KB Output is correct
49 Correct 1 ms 348 KB Output is correct
50 Correct 1 ms 348 KB Output is correct
51 Correct 0 ms 348 KB Output is correct
52 Correct 1 ms 348 KB Output is correct
53 Correct 0 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 452 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 1 ms 344 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 1 ms 348 KB Output is correct
16 Correct 1 ms 348 KB Output is correct
17 Correct 1 ms 348 KB Output is correct
18 Correct 1 ms 344 KB Output is correct
19 Correct 0 ms 348 KB Output is correct
20 Correct 0 ms 348 KB Output is correct
21 Correct 0 ms 460 KB Output is correct
22 Correct 0 ms 348 KB Output is correct
23 Correct 0 ms 348 KB Output is correct
24 Correct 1 ms 348 KB Output is correct
25 Correct 0 ms 456 KB Output is correct
26 Correct 0 ms 348 KB Output is correct
27 Correct 0 ms 600 KB Output is correct
28 Correct 1 ms 348 KB Output is correct
29 Correct 0 ms 348 KB Output is correct
30 Correct 0 ms 456 KB Output is correct
31 Correct 1 ms 348 KB Output is correct
32 Correct 0 ms 348 KB Output is correct
33 Correct 0 ms 344 KB Output is correct
34 Correct 0 ms 348 KB Output is correct
35 Correct 0 ms 348 KB Output is correct
36 Correct 1 ms 348 KB Output is correct
37 Correct 0 ms 348 KB Output is correct
38 Correct 0 ms 460 KB Output is correct
39 Correct 1 ms 348 KB Output is correct
40 Correct 1 ms 348 KB Output is correct
41 Correct 1 ms 348 KB Output is correct
42 Correct 1 ms 348 KB Output is correct
43 Correct 0 ms 348 KB Output is correct
44 Correct 0 ms 348 KB Output is correct
45 Correct 0 ms 420 KB Output is correct
46 Correct 0 ms 348 KB Output is correct
47 Correct 0 ms 348 KB Output is correct
48 Correct 0 ms 348 KB Output is correct
49 Correct 1 ms 348 KB Output is correct
50 Correct 1 ms 348 KB Output is correct
51 Correct 0 ms 348 KB Output is correct
52 Correct 1 ms 348 KB Output is correct
53 Correct 0 ms 348 KB Output is correct
54 Correct 2 ms 348 KB Output is correct
55 Correct 650 ms 956 KB Output is correct
56 Correct 2 ms 344 KB Output is correct
57 Correct 286 ms 784 KB Output is correct
58 Correct 171 ms 2644 KB Output is correct
59 Correct 1485 ms 18680 KB Output is correct
60 Correct 1489 ms 18476 KB Output is correct
61 Correct 1487 ms 18472 KB Output is correct
62 Correct 3 ms 848 KB Output is correct
63 Correct 1457 ms 17900 KB Output is correct
64 Correct 1434 ms 18544 KB Output is correct
65 Correct 1438 ms 18480 KB Output is correct
66 Correct 1413 ms 18516 KB Output is correct
67 Correct 1429 ms 18480 KB Output is correct
68 Correct 1415 ms 18800 KB Output is correct
69 Correct 1428 ms 18476 KB Output is correct
70 Correct 159 ms 2396 KB Output is correct
71 Correct 156 ms 2536 KB Output is correct
72 Correct 162 ms 2540 KB Output is correct
73 Correct 165 ms 2392 KB Output is correct
74 Correct 159 ms 2396 KB Output is correct
75 Correct 160 ms 2532 KB Output is correct
76 Correct 165 ms 2640 KB Output is correct
77 Correct 158 ms 2536 KB Output is correct
78 Correct 157 ms 2396 KB Output is correct
79 Correct 157 ms 2396 KB Output is correct
80 Correct 159 ms 2544 KB Output is correct
81 Correct 158 ms 2540 KB Output is correct
82 Correct 156 ms 2508 KB Output is correct
83 Correct 161 ms 2644 KB Output is correct
84 Correct 160 ms 2540 KB Output is correct
85 Correct 158 ms 2544 KB Output is correct
86 Correct 157 ms 2396 KB Output is correct
87 Correct 157 ms 2396 KB Output is correct
88 Correct 158 ms 2444 KB Output is correct
89 Correct 163 ms 2536 KB Output is correct
90 Correct 166 ms 2540 KB Output is correct