Submission #1153460

#TimeUsernameProblemLanguageResultExecution timeMemory
1153460spycoderytDango Maker (JOI18_dango_maker)C++20
0 / 100
0 ms396 KiB
#include <bits/stdc++.h>
using namespace std;

const int N = 3005;
int A[N][N],dp[N][N];
int main() {
    int n,m;
    cin>>n>>m;
    for(int i = 1;i<=n;i++) {
        for(int j = 1;j<=m;j++) {
            char c;
            cin>>c;
            if(c=='R')A[i][j]=1;
            else if (c == 'G') A[i][j] = 2;
            else A[i][j] = 3;
        }
    }
    for(int i = 1;i<=n;i++) {
        for(int j = 1;j<=m;j++) {
            // drag 
            dp[i][j] += dp[i-1][j] + dp[i][j-1] - dp[i-1][j-1];
            // hor
            int c1 = (A[i][j] == 1 && A[i][j+1] == 2 && A[i][j+2] == 3);
            int c2 = (A[i][j] == 1 && A[i+1][j] == 2 && A[i+2][j] == 3);
            if(c1)dp[i][j+2]++;
            if(c2)dp[i+2][j]++;
            if(c1&&c2)dp[i+2][j+2]--;
        }
    }
    // for(int i = 1;i<=n;i++) {
    //     for(int j = 1;j<=m;j++) {
    //         cout << dp[i][j] << " ";
    //     }cout << "\n";
    // }
    cout<<dp[n][m];
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...