답안 #787454

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
787454 2023-07-19T08:08:36 Z guagua0407 Dango Maker (JOI18_dango_maker) C++17
100 / 100
294 ms 124108 KB
//#pragma GCC optimize("O3")
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pii pair<int,int>
#define f first
#define s second
#define all(x) x.begin(),x.end()
#define _ ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);

void setIO(string s) {
    freopen((s + ".in").c_str(), "r", stdin);
    freopen((s + ".out").c_str(), "w", stdout);
}

const int mxn=3010;
char grid[mxn][mxn];
int dp[mxn][mxn][3];

int main() {_
    int n,m;
    cin>>n>>m;
    for(int i=0;i<mxn;i++){
        fill(grid[i],grid[i]+mxn,'.');
    }
    for(int i=1;i<=n;i++){
        for(int j=1;j<=m;j++){
            cin>>grid[i][j];
        }
    }
    for(int i=1;i<=n;i++){
        for(int j=1;j<=m;j++){
            if(grid[i-1][j]=='R' and grid[i][j]=='G' and grid[i+1][j]=='W'){
                dp[i][j][0]=1;
            }
            if(grid[i][j-1]=='R' and grid[i][j]=='G' and grid[i][j+1]=='W'){
                dp[i][j][1]=1;
            }
        }
    }
    int ans=0;
    for(int gap=2;gap<=n+m;gap++){
        int x,y;
        for(int i=1;i<=n;i++){
            int j=gap-i;
            if(j<1 or j>m) continue;
            dp[i][j][0]+=max(dp[i-1][j+1][0],dp[i-1][j+1][2]);
            dp[i][j][1]+=max(dp[i-1][j+1][1],dp[i-1][j+1][2]);
            dp[i][j][2]+=max({dp[i-1][j+1][0],dp[i-1][j+1][1],dp[i-1][j+1][2]});
            x=i,y=j;
        }
        //cout<<max({dp[x][y][0],dp[x][y][1],dp[x][y][2]})<<'\n';
        ans+=max({dp[x][y][0],dp[x][y][1],dp[x][y][2]});
    }
    cout<<ans<<'\n';
    return 0;
}
//maybe its multiset not set

Compilation message

dango_maker.cpp: In function 'void setIO(std::string)':
dango_maker.cpp:12:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   12 |     freopen((s + ".in").c_str(), "r", stdin);
      |     ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
dango_maker.cpp:13:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   13 |     freopen((s + ".out").c_str(), "w", stdout);
      |     ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
dango_maker.cpp: In function 'int main()':
dango_maker.cpp:53:53: warning: 'y' may be used uninitialized in this function [-Wmaybe-uninitialized]
   53 |         ans+=max({dp[x][y][0],dp[x][y][1],dp[x][y][2]});
      |                                           ~~~~~~~~~~^
dango_maker.cpp:53:53: warning: 'x' may be used uninitialized in this function [-Wmaybe-uninitialized]
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 9172 KB Output is correct
2 Correct 4 ms 9172 KB Output is correct
3 Correct 3 ms 9172 KB Output is correct
4 Correct 3 ms 9172 KB Output is correct
5 Correct 3 ms 9172 KB Output is correct
6 Correct 4 ms 9172 KB Output is correct
7 Correct 3 ms 9172 KB Output is correct
8 Correct 4 ms 9172 KB Output is correct
9 Correct 4 ms 9172 KB Output is correct
10 Correct 4 ms 9172 KB Output is correct
11 Correct 3 ms 9172 KB Output is correct
12 Correct 4 ms 9156 KB Output is correct
13 Correct 4 ms 9164 KB Output is correct
14 Correct 3 ms 9172 KB Output is correct
15 Correct 4 ms 9172 KB Output is correct
16 Correct 4 ms 9172 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 9172 KB Output is correct
2 Correct 4 ms 9172 KB Output is correct
3 Correct 3 ms 9172 KB Output is correct
4 Correct 3 ms 9172 KB Output is correct
5 Correct 3 ms 9172 KB Output is correct
6 Correct 4 ms 9172 KB Output is correct
7 Correct 3 ms 9172 KB Output is correct
8 Correct 4 ms 9172 KB Output is correct
9 Correct 4 ms 9172 KB Output is correct
10 Correct 4 ms 9172 KB Output is correct
11 Correct 3 ms 9172 KB Output is correct
12 Correct 4 ms 9156 KB Output is correct
13 Correct 4 ms 9164 KB Output is correct
14 Correct 3 ms 9172 KB Output is correct
15 Correct 4 ms 9172 KB Output is correct
16 Correct 4 ms 9172 KB Output is correct
17 Correct 4 ms 9172 KB Output is correct
18 Correct 3 ms 9156 KB Output is correct
19 Correct 4 ms 9172 KB Output is correct
20 Correct 4 ms 9172 KB Output is correct
21 Correct 4 ms 9156 KB Output is correct
22 Correct 4 ms 9172 KB Output is correct
23 Correct 4 ms 9172 KB Output is correct
24 Correct 4 ms 9172 KB Output is correct
25 Correct 3 ms 9172 KB Output is correct
26 Correct 3 ms 9160 KB Output is correct
27 Correct 4 ms 9172 KB Output is correct
28 Correct 3 ms 9172 KB Output is correct
29 Correct 3 ms 9164 KB Output is correct
30 Correct 4 ms 9172 KB Output is correct
31 Correct 4 ms 9172 KB Output is correct
32 Correct 4 ms 9172 KB Output is correct
33 Correct 4 ms 9236 KB Output is correct
34 Correct 4 ms 9172 KB Output is correct
35 Correct 3 ms 9172 KB Output is correct
36 Correct 3 ms 9172 KB Output is correct
37 Correct 3 ms 9172 KB Output is correct
38 Correct 4 ms 9172 KB Output is correct
39 Correct 3 ms 9172 KB Output is correct
40 Correct 3 ms 9172 KB Output is correct
41 Correct 4 ms 9172 KB Output is correct
42 Correct 4 ms 9160 KB Output is correct
43 Correct 4 ms 9172 KB Output is correct
44 Correct 4 ms 9172 KB Output is correct
45 Correct 4 ms 9172 KB Output is correct
46 Correct 4 ms 9172 KB Output is correct
47 Correct 4 ms 9168 KB Output is correct
48 Correct 4 ms 9156 KB Output is correct
49 Correct 4 ms 9160 KB Output is correct
50 Correct 3 ms 9172 KB Output is correct
51 Correct 4 ms 9172 KB Output is correct
52 Correct 3 ms 9156 KB Output is correct
53 Correct 4 ms 9172 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 9172 KB Output is correct
2 Correct 4 ms 9172 KB Output is correct
3 Correct 3 ms 9172 KB Output is correct
4 Correct 3 ms 9172 KB Output is correct
5 Correct 3 ms 9172 KB Output is correct
6 Correct 4 ms 9172 KB Output is correct
7 Correct 3 ms 9172 KB Output is correct
8 Correct 4 ms 9172 KB Output is correct
9 Correct 4 ms 9172 KB Output is correct
10 Correct 4 ms 9172 KB Output is correct
11 Correct 3 ms 9172 KB Output is correct
12 Correct 4 ms 9156 KB Output is correct
13 Correct 4 ms 9164 KB Output is correct
14 Correct 3 ms 9172 KB Output is correct
15 Correct 4 ms 9172 KB Output is correct
16 Correct 4 ms 9172 KB Output is correct
17 Correct 4 ms 9172 KB Output is correct
18 Correct 3 ms 9156 KB Output is correct
19 Correct 4 ms 9172 KB Output is correct
20 Correct 4 ms 9172 KB Output is correct
21 Correct 4 ms 9156 KB Output is correct
22 Correct 4 ms 9172 KB Output is correct
23 Correct 4 ms 9172 KB Output is correct
24 Correct 4 ms 9172 KB Output is correct
25 Correct 3 ms 9172 KB Output is correct
26 Correct 3 ms 9160 KB Output is correct
27 Correct 4 ms 9172 KB Output is correct
28 Correct 3 ms 9172 KB Output is correct
29 Correct 3 ms 9164 KB Output is correct
30 Correct 4 ms 9172 KB Output is correct
31 Correct 4 ms 9172 KB Output is correct
32 Correct 4 ms 9172 KB Output is correct
33 Correct 4 ms 9236 KB Output is correct
34 Correct 4 ms 9172 KB Output is correct
35 Correct 3 ms 9172 KB Output is correct
36 Correct 3 ms 9172 KB Output is correct
37 Correct 3 ms 9172 KB Output is correct
38 Correct 4 ms 9172 KB Output is correct
39 Correct 3 ms 9172 KB Output is correct
40 Correct 3 ms 9172 KB Output is correct
41 Correct 4 ms 9172 KB Output is correct
42 Correct 4 ms 9160 KB Output is correct
43 Correct 4 ms 9172 KB Output is correct
44 Correct 4 ms 9172 KB Output is correct
45 Correct 4 ms 9172 KB Output is correct
46 Correct 4 ms 9172 KB Output is correct
47 Correct 4 ms 9168 KB Output is correct
48 Correct 4 ms 9156 KB Output is correct
49 Correct 4 ms 9160 KB Output is correct
50 Correct 3 ms 9172 KB Output is correct
51 Correct 4 ms 9172 KB Output is correct
52 Correct 3 ms 9156 KB Output is correct
53 Correct 4 ms 9172 KB Output is correct
54 Correct 4 ms 9172 KB Output is correct
55 Correct 13 ms 21332 KB Output is correct
56 Correct 4 ms 9300 KB Output is correct
57 Correct 9 ms 17480 KB Output is correct
58 Correct 31 ms 25948 KB Output is correct
59 Correct 283 ms 123976 KB Output is correct
60 Correct 269 ms 123888 KB Output is correct
61 Correct 268 ms 123976 KB Output is correct
62 Correct 4 ms 9172 KB Output is correct
63 Correct 294 ms 123624 KB Output is correct
64 Correct 210 ms 124000 KB Output is correct
65 Correct 211 ms 124000 KB Output is correct
66 Correct 242 ms 124108 KB Output is correct
67 Correct 228 ms 123996 KB Output is correct
68 Correct 231 ms 123968 KB Output is correct
69 Correct 248 ms 123972 KB Output is correct
70 Correct 26 ms 25932 KB Output is correct
71 Correct 26 ms 25936 KB Output is correct
72 Correct 28 ms 25912 KB Output is correct
73 Correct 25 ms 25932 KB Output is correct
74 Correct 24 ms 25940 KB Output is correct
75 Correct 26 ms 25932 KB Output is correct
76 Correct 26 ms 25936 KB Output is correct
77 Correct 25 ms 25896 KB Output is correct
78 Correct 25 ms 25868 KB Output is correct
79 Correct 24 ms 25944 KB Output is correct
80 Correct 23 ms 25916 KB Output is correct
81 Correct 23 ms 25940 KB Output is correct
82 Correct 25 ms 25948 KB Output is correct
83 Correct 24 ms 25940 KB Output is correct
84 Correct 23 ms 25920 KB Output is correct
85 Correct 23 ms 25952 KB Output is correct
86 Correct 23 ms 25936 KB Output is correct
87 Correct 25 ms 25944 KB Output is correct
88 Correct 23 ms 25952 KB Output is correct
89 Correct 24 ms 25932 KB Output is correct
90 Correct 28 ms 25836 KB Output is correct