Submission #539883

# Submission time Handle Problem Language Result Execution time Memory
539883 2022-03-19T07:55:13 Z browntoad Dango Maker (JOI18_dango_maker) C++14
100 / 100
537 ms 185872 KB
#include <bits/stdc++.h>
#pragma GCC optimize ("Ofast", "unroll-loops")
using namespace std;
#define ll long long
#define int ll
#define FOR(i,a,b) for (int i = (a); i<(b); i++)
#define REP(i,n) FOR(i,0,n)
#define REP1(i,n) FOR(i,1,n+1)
#define RREP(i,n) for (int i=(n)-1; i>=0; i--)
#define RREP1(i,n) for (int i=(n); i>=1; i--)
#define f first
#define s second
#define pb push_back
#define ALL(x) x.begin(),x.end()
#define SZ(x) (int)(x.size())
#define SQ(x) (x)*(x)
#define pii pair<int, int>
#define pdd pair<double ,double>
#define pcc pair<char, char> 
#define endl '\n'
//#define TOAD
#ifdef TOAD
#define bug(x) cerr<<__LINE__<<": "<<#x<<" is "<<x<<endl
#define IOS()
#else
#define bug(...)
#define IOS() ios::sync_with_stdio(0), cin.tie(0), cout.tie(0)
#endif
 
const ll inf = 1ll<<60;
const int iinf=2147483647;
const ll mod = 1e9+7;
const ll maxn=3005;
const double PI=acos(-1);
 
ll pw(ll x, ll p, ll m=mod){
    ll ret=1;
    while (p>0){
        if (p&1){
            ret*=x;
            ret%=m;
        }
        x*=x;
        x%=m;
        p>>=1;
    }
    return ret;
}
 
ll inv(ll a, ll m=mod){
    return pw(a,m-2);
}
 
//=======================================================================================
char arr[maxn][maxn];
bool det(pii c, bool typ){
    if (typ) return (arr[c.f][c.s-1]=='R'&&arr[c.f][c.s]=='G'&&arr[c.f][c.s+1]=='W');
    else return (arr[c.f-1][c.s]=='R'&&arr[c.f][c.s]=='G'&&arr[c.f+1][c.s]=='W');
}
signed main (){
    IOS();
    int n, m; cin>>n>>m;
    vector<pii> run[n+m+1];
    REP1(i,n) REP1(j,m) {
        cin>>arr[i][j];
        run[i+j].pb({i, j});
    }
    int res=0;
    REP1(i, n+m){
        int dp0=0, dp1=0, dp2=0;
        REP(j,SZ(run[i])){
            int a=max({dp0, dp1, dp2});
            int b=(max(dp0, dp1)+1)*det(run[i][j], 0);
            int c=(max(dp0, dp2)+1)*det(run[i][j], 1);
            dp0=a; dp1=b; dp2=c;
        }
        res+=max({dp0, dp1, dp2});
    }
    cout<<res<<endl;
}   
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 384 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 212 KB Output is correct
10 Correct 1 ms 384 KB Output is correct
11 Correct 0 ms 340 KB Output is correct
12 Correct 0 ms 212 KB Output is correct
13 Correct 0 ms 212 KB Output is correct
14 Correct 1 ms 340 KB Output is correct
15 Correct 1 ms 340 KB Output is correct
16 Correct 0 ms 340 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 384 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 212 KB Output is correct
10 Correct 1 ms 384 KB Output is correct
11 Correct 0 ms 340 KB Output is correct
12 Correct 0 ms 212 KB Output is correct
13 Correct 0 ms 212 KB Output is correct
14 Correct 1 ms 340 KB Output is correct
15 Correct 1 ms 340 KB Output is correct
16 Correct 0 ms 340 KB Output is correct
17 Correct 0 ms 340 KB Output is correct
18 Correct 1 ms 340 KB Output is correct
19 Correct 1 ms 340 KB Output is correct
20 Correct 1 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 1 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 1 ms 256 KB Output is correct
27 Correct 1 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 1 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 1 ms 340 KB Output is correct
36 Correct 1 ms 388 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 1 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 1 ms 340 KB Output is correct
45 Correct 0 ms 352 KB Output is correct
46 Correct 1 ms 352 KB Output is correct
47 Correct 0 ms 352 KB Output is correct
48 Correct 1 ms 352 KB Output is correct
49 Correct 1 ms 348 KB Output is correct
50 Correct 1 ms 352 KB Output is correct
51 Correct 1 ms 384 KB Output is correct
52 Correct 1 ms 344 KB Output is correct
53 Correct 1 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 384 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 212 KB Output is correct
10 Correct 1 ms 384 KB Output is correct
11 Correct 0 ms 340 KB Output is correct
12 Correct 0 ms 212 KB Output is correct
13 Correct 0 ms 212 KB Output is correct
14 Correct 1 ms 340 KB Output is correct
15 Correct 1 ms 340 KB Output is correct
16 Correct 0 ms 340 KB Output is correct
17 Correct 0 ms 340 KB Output is correct
18 Correct 1 ms 340 KB Output is correct
19 Correct 1 ms 340 KB Output is correct
20 Correct 1 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 1 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 1 ms 256 KB Output is correct
27 Correct 1 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 1 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 1 ms 340 KB Output is correct
36 Correct 1 ms 388 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 1 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 1 ms 340 KB Output is correct
45 Correct 0 ms 352 KB Output is correct
46 Correct 1 ms 352 KB Output is correct
47 Correct 0 ms 352 KB Output is correct
48 Correct 1 ms 352 KB Output is correct
49 Correct 1 ms 348 KB Output is correct
50 Correct 1 ms 352 KB Output is correct
51 Correct 1 ms 384 KB Output is correct
52 Correct 1 ms 344 KB Output is correct
53 Correct 1 ms 348 KB Output is correct
54 Correct 1 ms 468 KB Output is correct
55 Correct 3 ms 9312 KB Output is correct
56 Correct 2 ms 852 KB Output is correct
57 Correct 4 ms 6508 KB Output is correct
58 Correct 43 ms 23588 KB Output is correct
59 Correct 438 ms 185776 KB Output is correct
60 Correct 495 ms 185684 KB Output is correct
61 Correct 537 ms 185776 KB Output is correct
62 Correct 1 ms 596 KB Output is correct
63 Correct 402 ms 181008 KB Output is correct
64 Correct 376 ms 185776 KB Output is correct
65 Correct 347 ms 185676 KB Output is correct
66 Correct 376 ms 185668 KB Output is correct
67 Correct 423 ms 185764 KB Output is correct
68 Correct 466 ms 185872 KB Output is correct
69 Correct 387 ms 185684 KB Output is correct
70 Correct 50 ms 23568 KB Output is correct
71 Correct 53 ms 23568 KB Output is correct
72 Correct 47 ms 23628 KB Output is correct
73 Correct 43 ms 23528 KB Output is correct
74 Correct 35 ms 23568 KB Output is correct
75 Correct 44 ms 23552 KB Output is correct
76 Correct 46 ms 23532 KB Output is correct
77 Correct 46 ms 23616 KB Output is correct
78 Correct 39 ms 23532 KB Output is correct
79 Correct 43 ms 23572 KB Output is correct
80 Correct 39 ms 23628 KB Output is correct
81 Correct 38 ms 23652 KB Output is correct
82 Correct 37 ms 23624 KB Output is correct
83 Correct 33 ms 23620 KB Output is correct
84 Correct 45 ms 23596 KB Output is correct
85 Correct 34 ms 23532 KB Output is correct
86 Correct 38 ms 23632 KB Output is correct
87 Correct 41 ms 23648 KB Output is correct
88 Correct 38 ms 23516 KB Output is correct
89 Correct 65 ms 23568 KB Output is correct
90 Correct 36 ms 23648 KB Output is correct