답안 #924835

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
924835 2024-02-09T20:16:22 Z SalihSahin Dango Maker (JOI18_dango_maker) C++17
100 / 100
350 ms 19684 KB
#include<bits/stdc++.h>
#define pb push_back
#define int long long
#define mp make_pair
using namespace std;
 
const int mod = 998244353;
const int inf = 1e16;
const int N = 55;

int32_t main(){
    cin.tie(0); cout.tie(0);
    ios_base::sync_with_stdio(false);
    int n, m;
    cin>>n>>m;
    vector<vector<char> > a(n, vector<char>(m));
    vector<vector<bool> > vis(n, vector<bool>(m));
    for(int i = 0; i < n; i++){
        for(int j = 0; j < m; j++){
            cin>>a[i][j];
        }
    }
    int ans = 0;

    for(int i = 0; i < n; i++){
        for(int j = 0; j < m; j++){
            if(a[i][j] == 'G' && !vis[i][j]){
                vis[i][j] = 1;
                int cnt = 1;
                while(i + cnt < n && j - cnt >= 0){
                    if(a[i + cnt][j - cnt] == 'G'){
                        vis[i + cnt][j - cnt] = 1;
                        cnt++;
                    }
                    else break;
                }

                vector<vector<int> > dp(cnt+1, vector<int>(3)); // 0 = none, 1 = left to right, 2 = up to down
                for(int k = 1; k <= cnt; k++){
                    dp[k][0] = max({dp[k-1][0], dp[k-1][1], dp[k-1][2]});
                    int y = i + (k-1), x = j - (k-1);
                    if(x - 1 >= 0 && x + 1 < m && a[y][x-1] == 'R' && a[y][x+1] == 'W'){
                        dp[k][1] = max({dp[k-1][0] + 1, dp[k-1][1] + 1});
                    }
                    if(y - 1 >= 0 && y + 1 < n && a[y-1][x] == 'R' && a[y+1][x] == 'W'){
                        dp[k][2] = max({dp[k-1][0] + 1, dp[k-1][2] + 1});
                    }
                }

                ans += max({dp[cnt][0], dp[cnt][1], dp[cnt][2]});
            }
        }
    }

    cout<<ans<<endl;
    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 0 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 0 ms 348 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 452 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 0 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 0 ms 348 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 452 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
17 Correct 1 ms 600 KB Output is correct
18 Correct 0 ms 348 KB Output is correct
19 Correct 0 ms 348 KB Output is correct
20 Correct 0 ms 348 KB Output is correct
21 Correct 1 ms 348 KB Output is correct
22 Correct 0 ms 348 KB Output is correct
23 Correct 0 ms 344 KB Output is correct
24 Correct 0 ms 348 KB Output is correct
25 Correct 0 ms 348 KB Output is correct
26 Correct 0 ms 348 KB Output is correct
27 Correct 0 ms 460 KB Output is correct
28 Correct 0 ms 348 KB Output is correct
29 Correct 0 ms 348 KB Output is correct
30 Correct 0 ms 348 KB Output is correct
31 Correct 0 ms 344 KB Output is correct
32 Correct 1 ms 600 KB Output is correct
33 Correct 0 ms 348 KB Output is correct
34 Correct 0 ms 348 KB Output is correct
35 Correct 0 ms 344 KB Output is correct
36 Correct 1 ms 344 KB Output is correct
37 Correct 1 ms 344 KB Output is correct
38 Correct 0 ms 348 KB Output is correct
39 Correct 1 ms 348 KB Output is correct
40 Correct 0 ms 348 KB Output is correct
41 Correct 0 ms 344 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 348 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 0 ms 348 KB Output is correct
50 Correct 1 ms 348 KB Output is correct
51 Correct 0 ms 460 KB Output is correct
52 Correct 0 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 1 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 0 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 0 ms 348 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 452 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
17 Correct 1 ms 600 KB Output is correct
18 Correct 0 ms 348 KB Output is correct
19 Correct 0 ms 348 KB Output is correct
20 Correct 0 ms 348 KB Output is correct
21 Correct 1 ms 348 KB Output is correct
22 Correct 0 ms 348 KB Output is correct
23 Correct 0 ms 344 KB Output is correct
24 Correct 0 ms 348 KB Output is correct
25 Correct 0 ms 348 KB Output is correct
26 Correct 0 ms 348 KB Output is correct
27 Correct 0 ms 460 KB Output is correct
28 Correct 0 ms 348 KB Output is correct
29 Correct 0 ms 348 KB Output is correct
30 Correct 0 ms 348 KB Output is correct
31 Correct 0 ms 344 KB Output is correct
32 Correct 1 ms 600 KB Output is correct
33 Correct 0 ms 348 KB Output is correct
34 Correct 0 ms 348 KB Output is correct
35 Correct 0 ms 344 KB Output is correct
36 Correct 1 ms 344 KB Output is correct
37 Correct 1 ms 344 KB Output is correct
38 Correct 0 ms 348 KB Output is correct
39 Correct 1 ms 348 KB Output is correct
40 Correct 0 ms 348 KB Output is correct
41 Correct 0 ms 344 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 348 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 0 ms 348 KB Output is correct
50 Correct 1 ms 348 KB Output is correct
51 Correct 0 ms 460 KB Output is correct
52 Correct 0 ms 348 KB Output is correct
53 Correct 0 ms 348 KB Output is correct
54 Correct 0 ms 348 KB Output is correct
55 Correct 1 ms 604 KB Output is correct
56 Correct 1 ms 348 KB Output is correct
57 Correct 1 ms 604 KB Output is correct
58 Correct 35 ms 2524 KB Output is correct
59 Correct 318 ms 19380 KB Output is correct
60 Correct 324 ms 19152 KB Output is correct
61 Correct 350 ms 19392 KB Output is correct
62 Correct 1 ms 348 KB Output is correct
63 Correct 304 ms 18728 KB Output is correct
64 Correct 220 ms 19684 KB Output is correct
65 Correct 222 ms 19544 KB Output is correct
66 Correct 253 ms 19540 KB Output is correct
67 Correct 259 ms 19376 KB Output is correct
68 Correct 275 ms 19376 KB Output is correct
69 Correct 271 ms 19376 KB Output is correct
70 Correct 23 ms 2904 KB Output is correct
71 Correct 25 ms 2652 KB Output is correct
72 Correct 24 ms 2680 KB Output is correct
73 Correct 27 ms 2648 KB Output is correct
74 Correct 24 ms 2624 KB Output is correct
75 Correct 24 ms 2648 KB Output is correct
76 Correct 26 ms 2648 KB Output is correct
77 Correct 27 ms 2524 KB Output is correct
78 Correct 25 ms 2652 KB Output is correct
79 Correct 24 ms 2664 KB Output is correct
80 Correct 24 ms 2648 KB Output is correct
81 Correct 24 ms 2652 KB Output is correct
82 Correct 25 ms 2652 KB Output is correct
83 Correct 24 ms 2652 KB Output is correct
84 Correct 27 ms 2724 KB Output is correct
85 Correct 24 ms 2652 KB Output is correct
86 Correct 25 ms 2652 KB Output is correct
87 Correct 25 ms 2652 KB Output is correct
88 Correct 25 ms 2652 KB Output is correct
89 Correct 25 ms 2652 KB Output is correct
90 Correct 25 ms 2648 KB Output is correct