Submission #814983

# Submission time Handle Problem Language Result Execution time Memory
814983 2023-08-08T11:32:57 Z trucmai Dango Maker (JOI18_dango_maker) C++17
100 / 100
274 ms 226176 KB
#include <bits/stdc++.h>
using namespace std;

#ifdef LOCAL
  #include "/home/trucmai/.vim/tools.h"
  #define debug(x...) cerr << "\e[91m"<<__func__<<":"<<__LINE__<<" [" << #x << "] = ["; _print(x); cerr << "\e[39m" << endl;
  #else
  #define debug(x...)
#endif

void open(){
  if(fopen("i.inp","r")){
    freopen("i.inp","r",stdin);
    freopen("o.out","w",stdout);
  }
}

#define ll int
#define all(a) (a).begin(), (a).end()
#define vi vector<ll>
#define pi pair<ll,ll>
#define pii pair<ll,pair<ll,ll>>
#define fi first
#define se second
#define gcd __gcd
#define mset(a,v) memset(a, v, sizeof(a))
#define endl '\n'
#define spc " "

const int MN = 3001,LOG = 27;
const ll MOD = 1e9 + 7,INF = 1e9;
ll n,m,dp[MN][MN][3],dango[MN][MN][3];
char a[MN][MN];
void solve(){
  cin>>n>>m; 
  for(ll i = 1;i <= n;++i)
    for(ll j = 1;j <= m;++j) cin>>a[i][j]; 
  for(ll i = 1;i <= n;++i)
    for(ll j = 1;j <= m;++j){
      if(a[i-1][j] == 'R' && a[i][j] == 'G' && a[i+1][j] == 'W') dango[i][j][1] = 1; 
      if(a[i][j-1] == 'R' && a[i][j] == 'G' && a[i][j+1] == 'W') dango[i][j][2] = 1;
    }
  for(ll i = 1;i <= n;++i){
    for(ll 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]}) + dango[i][j][1];
      dp[i][j][2] += max({dp[i-1][j+1][0],dp[i-1][j+1][2]}) + dango[i][j][2];
    }
  }
  ll res = 0; 
  for(ll i = 1;i <= n;++i)
    res += max({dp[i][1][0],dp[i][1][1],dp[i][1][2]}); 
  for(ll i = 2;i <= m;++i)
    res += max({dp[n][i][0],dp[n][i][1],dp[n][i][2]});
  cout<<res<<endl;
}

signed main(){
  cin.tie(0) -> sync_with_stdio(0);
  open();
  ll t = 1; //cin>>t;
  while(t--) solve(); 
  cerr << endl << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
}

Compilation message

dango_maker.cpp: In function 'void open()':
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("i.inp","r",stdin);
      |     ~~~~~~~^~~~~~~~~~~~~~~~~~~
dango_maker.cpp:14:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   14 |     freopen("o.out","w",stdout);
      |     ~~~~~~~^~~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 0 ms 340 KB Output is correct
2 Correct 1 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 0 ms 340 KB Output is correct
6 Correct 0 ms 340 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 0 ms 340 KB Output is correct
9 Correct 1 ms 340 KB Output is correct
10 Correct 0 ms 340 KB Output is correct
11 Correct 0 ms 340 KB Output is correct
12 Correct 0 ms 340 KB Output is correct
13 Correct 0 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 0 ms 340 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 340 KB Output is correct
2 Correct 1 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 0 ms 340 KB Output is correct
6 Correct 0 ms 340 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 0 ms 340 KB Output is correct
9 Correct 1 ms 340 KB Output is correct
10 Correct 0 ms 340 KB Output is correct
11 Correct 0 ms 340 KB Output is correct
12 Correct 0 ms 340 KB Output is correct
13 Correct 0 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 0 ms 340 KB Output is correct
17 Correct 1 ms 340 KB Output is correct
18 Correct 0 ms 340 KB Output is correct
19 Correct 1 ms 340 KB Output is correct
20 Correct 0 ms 340 KB Output is correct
21 Correct 0 ms 340 KB Output is correct
22 Correct 0 ms 340 KB Output is correct
23 Correct 0 ms 340 KB Output is correct
24 Correct 1 ms 340 KB Output is correct
25 Correct 0 ms 340 KB Output is correct
26 Correct 0 ms 340 KB Output is correct
27 Correct 0 ms 340 KB Output is correct
28 Correct 1 ms 340 KB Output is correct
29 Correct 0 ms 340 KB Output is correct
30 Correct 0 ms 340 KB Output is correct
31 Correct 1 ms 340 KB Output is correct
32 Correct 0 ms 340 KB Output is correct
33 Correct 0 ms 340 KB Output is correct
34 Correct 0 ms 340 KB Output is correct
35 Correct 0 ms 340 KB Output is correct
36 Correct 1 ms 340 KB Output is correct
37 Correct 1 ms 340 KB Output is correct
38 Correct 1 ms 340 KB Output is correct
39 Correct 1 ms 340 KB Output is correct
40 Correct 0 ms 340 KB Output is correct
41 Correct 0 ms 340 KB Output is correct
42 Correct 0 ms 340 KB Output is correct
43 Correct 0 ms 340 KB Output is correct
44 Correct 0 ms 340 KB Output is correct
45 Correct 0 ms 340 KB Output is correct
46 Correct 0 ms 340 KB Output is correct
47 Correct 1 ms 340 KB Output is correct
48 Correct 0 ms 340 KB Output is correct
49 Correct 0 ms 340 KB Output is correct
50 Correct 1 ms 340 KB Output is correct
51 Correct 0 ms 340 KB Output is correct
52 Correct 0 ms 340 KB Output is correct
53 Correct 0 ms 340 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 340 KB Output is correct
2 Correct 1 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 0 ms 340 KB Output is correct
6 Correct 0 ms 340 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 0 ms 340 KB Output is correct
9 Correct 1 ms 340 KB Output is correct
10 Correct 0 ms 340 KB Output is correct
11 Correct 0 ms 340 KB Output is correct
12 Correct 0 ms 340 KB Output is correct
13 Correct 0 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 0 ms 340 KB Output is correct
17 Correct 1 ms 340 KB Output is correct
18 Correct 0 ms 340 KB Output is correct
19 Correct 1 ms 340 KB Output is correct
20 Correct 0 ms 340 KB Output is correct
21 Correct 0 ms 340 KB Output is correct
22 Correct 0 ms 340 KB Output is correct
23 Correct 0 ms 340 KB Output is correct
24 Correct 1 ms 340 KB Output is correct
25 Correct 0 ms 340 KB Output is correct
26 Correct 0 ms 340 KB Output is correct
27 Correct 0 ms 340 KB Output is correct
28 Correct 1 ms 340 KB Output is correct
29 Correct 0 ms 340 KB Output is correct
30 Correct 0 ms 340 KB Output is correct
31 Correct 1 ms 340 KB Output is correct
32 Correct 0 ms 340 KB Output is correct
33 Correct 0 ms 340 KB Output is correct
34 Correct 0 ms 340 KB Output is correct
35 Correct 0 ms 340 KB Output is correct
36 Correct 1 ms 340 KB Output is correct
37 Correct 1 ms 340 KB Output is correct
38 Correct 1 ms 340 KB Output is correct
39 Correct 1 ms 340 KB Output is correct
40 Correct 0 ms 340 KB Output is correct
41 Correct 0 ms 340 KB Output is correct
42 Correct 0 ms 340 KB Output is correct
43 Correct 0 ms 340 KB Output is correct
44 Correct 0 ms 340 KB Output is correct
45 Correct 0 ms 340 KB Output is correct
46 Correct 0 ms 340 KB Output is correct
47 Correct 1 ms 340 KB Output is correct
48 Correct 0 ms 340 KB Output is correct
49 Correct 0 ms 340 KB Output is correct
50 Correct 1 ms 340 KB Output is correct
51 Correct 0 ms 340 KB Output is correct
52 Correct 0 ms 340 KB Output is correct
53 Correct 0 ms 340 KB Output is correct
54 Correct 1 ms 340 KB Output is correct
55 Correct 8 ms 21936 KB Output is correct
56 Correct 1 ms 596 KB Output is correct
57 Correct 7 ms 21588 KB Output is correct
58 Correct 28 ms 34388 KB Output is correct
59 Correct 241 ms 225212 KB Output is correct
60 Correct 274 ms 226000 KB Output is correct
61 Correct 269 ms 226048 KB Output is correct
62 Correct 1 ms 468 KB Output is correct
63 Correct 251 ms 226176 KB Output is correct
64 Correct 200 ms 225976 KB Output is correct
65 Correct 173 ms 226028 KB Output is correct
66 Correct 190 ms 225984 KB Output is correct
67 Correct 175 ms 159616 KB Output is correct
68 Correct 159 ms 159724 KB Output is correct
69 Correct 204 ms 166724 KB Output is correct
70 Correct 25 ms 35680 KB Output is correct
71 Correct 24 ms 35688 KB Output is correct
72 Correct 26 ms 35744 KB Output is correct
73 Correct 26 ms 35740 KB Output is correct
74 Correct 26 ms 35692 KB Output is correct
75 Correct 26 ms 35652 KB Output is correct
76 Correct 25 ms 35660 KB Output is correct
77 Correct 25 ms 35660 KB Output is correct
78 Correct 25 ms 35748 KB Output is correct
79 Correct 25 ms 35704 KB Output is correct
80 Correct 24 ms 35776 KB Output is correct
81 Correct 26 ms 35776 KB Output is correct
82 Correct 24 ms 35656 KB Output is correct
83 Correct 24 ms 35660 KB Output is correct
84 Correct 24 ms 35672 KB Output is correct
85 Correct 26 ms 35708 KB Output is correct
86 Correct 24 ms 35656 KB Output is correct
87 Correct 24 ms 35660 KB Output is correct
88 Correct 25 ms 35656 KB Output is correct
89 Correct 24 ms 35676 KB Output is correct
90 Correct 30 ms 35712 KB Output is correct