답안 #1018059

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1018059 2024-07-09T13:31:57 Z phong Dango Maker (JOI18_dango_maker) C++17
100 / 100
339 ms 124320 KB
#include<bits/stdc++.h>

#define ll long long
//#define int long long
const int nmax = 3000 + 5, N = 4e5;
const ll oo = 1e9;
const int lg = 18, M = 4e3;
const int base = 2e5, mod = 1e9 + 7;
#define pii pair<int, int>
#define fi first
#define se second
#define endl "\n"
#define debug(a, n) for(int i = 1; i <= n; ++i) cout << a[i] << ' ';cout << endl
using namespace std;
const double eps = 1e-9;

int n, m;
char a[nmax][nmax];
pii adj[nmax * 3];
int dp[nmax][nmax][3];
bool ok(int i, int j, int id){
    if(id == 1){
        return a[i][j - 1] == 'R' && a[i][j] == 'G' && a[i][j + 1] == 'W';
    }
    else{
        return a[i - 1][j] == 'R' && a[i][j] == 'G' && a[i + 1][j] == 'W';
    }
}
main(){
//        freopen("code.inp", "r", stdin);
//        freopen("code.out", "w", stdout);
    cin >> n>> m;
    for(int i = 1; i <= n; ++i){
        for(int j = 1; j <= m; ++j){
            cin >> a[i][j];
            adj[i + j] ={i, j};
        }
    }
    for(int i = 1; i <= n; ++i){
        for(int j = 1; j <= m; ++j){
            dp[i][j][0] = max({dp[i - 1][j + 1][0], dp[i - 1][j + 1][1], dp[i - 1][j + 1][2]});
            dp[i][j][1] = max(dp[i - 1][j + 1][0], dp[i - 1][j + 1][1])+ ok(i, j, 1);
            dp[i][j][2] = max(dp[i - 1][j + 1][0], dp[i - 1][j + 1][2])+ ok(i, j, 2);

        }
    }
//    cout<< dp[3][2][0] << ' ';
    int ans = 0;
    for(int i = 2; i <= n + m; ++i){
        int x = adj[i].fi;
        int y = adj[i].se;
        ans += max({dp[x][y][0], dp[x][y][1],dp[x][y][2]});
//        cout << x << ' ' << y << ' ' <<max({dp[x][y][0], dp[x][y][1],dp[x][y][2]})<< endl;
    }
    cout << ans;
}

Compilation message

dango_maker.cpp:29:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   29 | main(){
      | ^~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2396 KB Output is correct
2 Correct 0 ms 2396 KB Output is correct
3 Correct 0 ms 2396 KB Output is correct
4 Correct 1 ms 2396 KB Output is correct
5 Correct 0 ms 2396 KB Output is correct
6 Correct 0 ms 2396 KB Output is correct
7 Correct 0 ms 2396 KB Output is correct
8 Correct 0 ms 2396 KB Output is correct
9 Correct 0 ms 2396 KB Output is correct
10 Correct 0 ms 2396 KB Output is correct
11 Correct 0 ms 2396 KB Output is correct
12 Correct 1 ms 2396 KB Output is correct
13 Correct 0 ms 2396 KB Output is correct
14 Correct 0 ms 2396 KB Output is correct
15 Correct 0 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 0 ms 2396 KB Output is correct
3 Correct 0 ms 2396 KB Output is correct
4 Correct 1 ms 2396 KB Output is correct
5 Correct 0 ms 2396 KB Output is correct
6 Correct 0 ms 2396 KB Output is correct
7 Correct 0 ms 2396 KB Output is correct
8 Correct 0 ms 2396 KB Output is correct
9 Correct 0 ms 2396 KB Output is correct
10 Correct 0 ms 2396 KB Output is correct
11 Correct 0 ms 2396 KB Output is correct
12 Correct 1 ms 2396 KB Output is correct
13 Correct 0 ms 2396 KB Output is correct
14 Correct 0 ms 2396 KB Output is correct
15 Correct 0 ms 2396 KB Output is correct
16 Correct 1 ms 2396 KB Output is correct
17 Correct 1 ms 2396 KB Output is correct
18 Correct 1 ms 4444 KB Output is correct
19 Correct 1 ms 4444 KB Output is correct
20 Correct 1 ms 4444 KB Output is correct
21 Correct 1 ms 4444 KB Output is correct
22 Correct 1 ms 4444 KB Output is correct
23 Correct 1 ms 4444 KB Output is correct
24 Correct 1 ms 4444 KB Output is correct
25 Correct 1 ms 4444 KB Output is correct
26 Correct 0 ms 2396 KB Output is correct
27 Correct 1 ms 4444 KB Output is correct
28 Correct 1 ms 4444 KB Output is correct
29 Correct 1 ms 4444 KB Output is correct
30 Correct 1 ms 4444 KB Output is correct
31 Correct 1 ms 4444 KB Output is correct
32 Correct 1 ms 4444 KB Output is correct
33 Correct 1 ms 4440 KB Output is correct
34 Correct 1 ms 4444 KB Output is correct
35 Correct 1 ms 4444 KB Output is correct
36 Correct 1 ms 4444 KB Output is correct
37 Correct 1 ms 4540 KB Output is correct
38 Correct 1 ms 4440 KB Output is correct
39 Correct 1 ms 4492 KB Output is correct
40 Correct 1 ms 4444 KB Output is correct
41 Correct 1 ms 4444 KB Output is correct
42 Correct 1 ms 4444 KB Output is correct
43 Correct 1 ms 4444 KB Output is correct
44 Correct 1 ms 4444 KB Output is correct
45 Correct 1 ms 4444 KB Output is correct
46 Correct 1 ms 4444 KB Output is correct
47 Correct 1 ms 4444 KB Output is correct
48 Correct 1 ms 4444 KB Output is correct
49 Correct 1 ms 4444 KB Output is correct
50 Correct 1 ms 4444 KB Output is correct
51 Correct 1 ms 4444 KB Output is correct
52 Correct 1 ms 4444 KB Output is correct
53 Correct 1 ms 4444 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2396 KB Output is correct
2 Correct 0 ms 2396 KB Output is correct
3 Correct 0 ms 2396 KB Output is correct
4 Correct 1 ms 2396 KB Output is correct
5 Correct 0 ms 2396 KB Output is correct
6 Correct 0 ms 2396 KB Output is correct
7 Correct 0 ms 2396 KB Output is correct
8 Correct 0 ms 2396 KB Output is correct
9 Correct 0 ms 2396 KB Output is correct
10 Correct 0 ms 2396 KB Output is correct
11 Correct 0 ms 2396 KB Output is correct
12 Correct 1 ms 2396 KB Output is correct
13 Correct 0 ms 2396 KB Output is correct
14 Correct 0 ms 2396 KB Output is correct
15 Correct 0 ms 2396 KB Output is correct
16 Correct 1 ms 2396 KB Output is correct
17 Correct 1 ms 2396 KB Output is correct
18 Correct 1 ms 4444 KB Output is correct
19 Correct 1 ms 4444 KB Output is correct
20 Correct 1 ms 4444 KB Output is correct
21 Correct 1 ms 4444 KB Output is correct
22 Correct 1 ms 4444 KB Output is correct
23 Correct 1 ms 4444 KB Output is correct
24 Correct 1 ms 4444 KB Output is correct
25 Correct 1 ms 4444 KB Output is correct
26 Correct 0 ms 2396 KB Output is correct
27 Correct 1 ms 4444 KB Output is correct
28 Correct 1 ms 4444 KB Output is correct
29 Correct 1 ms 4444 KB Output is correct
30 Correct 1 ms 4444 KB Output is correct
31 Correct 1 ms 4444 KB Output is correct
32 Correct 1 ms 4444 KB Output is correct
33 Correct 1 ms 4440 KB Output is correct
34 Correct 1 ms 4444 KB Output is correct
35 Correct 1 ms 4444 KB Output is correct
36 Correct 1 ms 4444 KB Output is correct
37 Correct 1 ms 4540 KB Output is correct
38 Correct 1 ms 4440 KB Output is correct
39 Correct 1 ms 4492 KB Output is correct
40 Correct 1 ms 4444 KB Output is correct
41 Correct 1 ms 4444 KB Output is correct
42 Correct 1 ms 4444 KB Output is correct
43 Correct 1 ms 4444 KB Output is correct
44 Correct 1 ms 4444 KB Output is correct
45 Correct 1 ms 4444 KB Output is correct
46 Correct 1 ms 4444 KB Output is correct
47 Correct 1 ms 4444 KB Output is correct
48 Correct 1 ms 4444 KB Output is correct
49 Correct 1 ms 4444 KB Output is correct
50 Correct 1 ms 4444 KB Output is correct
51 Correct 1 ms 4444 KB Output is correct
52 Correct 1 ms 4444 KB Output is correct
53 Correct 1 ms 4444 KB Output is correct
54 Correct 1 ms 2396 KB Output is correct
55 Correct 8 ms 71496 KB Output is correct
56 Correct 1 ms 4700 KB Output is correct
57 Correct 7 ms 69436 KB Output is correct
58 Correct 38 ms 43440 KB Output is correct
59 Correct 339 ms 123988 KB Output is correct
60 Correct 338 ms 124320 KB Output is correct
61 Correct 335 ms 123984 KB Output is correct
62 Correct 1 ms 2392 KB Output is correct
63 Correct 332 ms 123640 KB Output is correct
64 Correct 279 ms 123984 KB Output is correct
65 Correct 278 ms 123988 KB Output is correct
66 Correct 289 ms 123944 KB Output is correct
67 Correct 286 ms 123940 KB Output is correct
68 Correct 281 ms 123988 KB Output is correct
69 Correct 281 ms 123988 KB Output is correct
70 Correct 34 ms 44376 KB Output is correct
71 Correct 32 ms 44464 KB Output is correct
72 Correct 39 ms 44372 KB Output is correct
73 Correct 32 ms 44380 KB Output is correct
74 Correct 33 ms 44440 KB Output is correct
75 Correct 32 ms 44380 KB Output is correct
76 Correct 32 ms 44372 KB Output is correct
77 Correct 32 ms 44560 KB Output is correct
78 Correct 40 ms 44368 KB Output is correct
79 Correct 33 ms 44368 KB Output is correct
80 Correct 33 ms 44432 KB Output is correct
81 Correct 34 ms 44368 KB Output is correct
82 Correct 33 ms 44332 KB Output is correct
83 Correct 32 ms 44368 KB Output is correct
84 Correct 32 ms 44368 KB Output is correct
85 Correct 33 ms 44328 KB Output is correct
86 Correct 33 ms 44328 KB Output is correct
87 Correct 33 ms 44544 KB Output is correct
88 Correct 33 ms 44460 KB Output is correct
89 Correct 35 ms 44368 KB Output is correct
90 Correct 33 ms 44328 KB Output is correct