Submission #364968

# Submission time Handle Problem Language Result Execution time Memory
364968 2021-02-10T16:08:17 Z farhan132 Dango Maker (JOI18_dango_maker) C++17
0 / 100
143 ms 262148 KB
/***Farhan132***/

#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
typedef unsigned long long ull;
typedef double dd;
typedef vector<ll> vll;
typedef pair<ll , ll> ii;
typedef vector< ii > vi;
typedef pair < pair < ll , ll > , pair < ll , ll > > cm; 
 
#define ff first
#define ss second
#define pb push_back
#define in insert
#define f0(b) for(int i=0;i<(b);i++)
#define f00(b) for(int j=0;j<(b);j++)
#define f1(b) for(int i=1;i<=(b);i++)
#define f11(b) for(int j=1;j<=(b);j++)
#define f2(a,b) for(int i=(a);i<=(b);i++)
#define f22(a,b) for(int j=(a);j<=(b);j++)
#define sf(a) scanf("%lld",&a)
#define sff(a,b) scanf("%lld %lld", &a , &b)
#define pf(a) printf("%lld\n",a)
#define pff(a,b) printf("%lld %lld\n", a , b)
#define PI 3.14159265359
#define bug printf("**!\n")
#define mem(a , b) memset(a, b ,sizeof(a))
#define front_zero(n) __builtin_clzll(n)
#define back_zero(n) __builtin_ctzll(n)
#define total_one(n) __builtin_popcountll(n)
#define clean fflush(stdout)

const ll mod =  (ll)1e9 + 7;
const ll maxn = (ll)2e5 + 5;
const int nnn = 1048590;
const int inf = numeric_limits<int>::max()-1;
//const ll INF = numeric_limits<ll>::max()-1;
//const ll INF = 1e18;
 
ll dx[]={0,1,0,-1};
ll dy[]={1,0,-1,0};
ll dxx[]={0,1,0,-1,1,1,-1,-1};
ll dyy[]={1,0,-1,0,1,-1,1,-1};


ll dp[4][3005][3005];
char a[3005][3005];

ll sum[60010];

void solve(){

    mem(a, 'A');
    mem(sum , 0);
    mem(dp, 0);
    ll n , m;
    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++){
            dp[0][i][j] = max({dp[0][i-1][j+1] , dp[1][i-1][j+1] , dp[2][i-1][j+1]});
            if(a[i][j] == 'G' && a[i][j+1] == 'W' && a[i][j-1] == 'R') dp[1][i][j] = max(dp[1][i-1][j+1], dp[0][i-1][j+1]) + 1;
            if(a[i][j] == 'G' && a[i-1][j] == 'R' && a[i+1][j] == 'W') dp[2][i][j] = max(dp[2][i-1][j+1], dp[0][i-1][j+1]) + 1;
            sum[i + j] = max(sum[i + j] , max({dp[0][i][j] , dp[1][i][j] , dp[2][i][j]}));
        }
    }
    ll ans = 0;
    for(ll i = 2; i <= n+m; i++) ans += sum[i];
    cout << ans;
    
    return;
    
}

 
int main() {
    
    
    #ifdef LOCAL
        freopen("in.txt", "r", stdin);
        freopen("out.txt", "w", stdout);
    #else 
     //   freopen("cbarn2.in", "r", stdin);
     //   freopen("cbarn2.out", "w", stdout);
     ios_base::sync_with_stdio(0); cin.tie(NULL); cout.tie(NULL);
    #endif
    //cout << fixed << setprecision(10);
   // work(maxn);
    //  mem(b,0);
    ll T;
    T=1;
    //cin >> T; 
    //scanf("%lld",&T);
   // ll CT = 0;
    //work();
    while(T--){
        //cout << "Case " << ++CT <<": " ;
        //printf("Case %lld: ",++CT);
        solve();
    }
 
    return 0;
}
# Verdict Execution time Memory Grader output
1 Runtime error 143 ms 262148 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 143 ms 262148 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 143 ms 262148 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -