Submission #1115361

# Submission time Handle Problem Language Result Execution time Memory
1115361 2024-11-20T11:26:20 Z staszic_ojuz Dango Maker (JOI18_dango_maker) C++17
0 / 100
1 ms 592 KB
#include <iostream>
#include <vector>
using namespace std;
int main(){
    int n, m;
    cin>>n>>m;
    vector<string> vect(n);
    for (int i=0;i<n;i++) cin>>vect[i];
    vector<vector<int>> dp(n);
    vector<vector<bool>> used(n);
    for (int i=0;i<n;i++){
        dp[i].resize(m);
        used[i].resize(m);
    }
    for (int i=0;i<n;i++){
        for (int j=0;j<m;j++){
            if (i>0) dp[i][j]+=dp[i-1][j];
            if (j>0) dp[i][j]+=dp[i][j-1];
            if (i>0&&j>0) dp[i][j]-=dp[i-1][j-1];
            if (i>=2&&j>=2){
                if ((((vect[i][j]=='W'&&vect[i-1][j]=='G'&&vect[i-2][j]=='R')||(vect[i][j]=='R'&&vect[i-1][j]=='G'&&vect[i-2][j]=='W'))&&!used[i-1][j]&&!used[i-2][j])&&(((vect[i][j]=='W'&&vect[i][j-1]=='G'&&vect[i][j-2]=='R')||(vect[i][j]=='R'&&vect[i][j-1]=='G'&&vect[i][j-2]=='W'))&&!used[i][j-1]&&!used[i][j-2])){
                    if (dp[i-1][j]>dp[i][j-1]){
                        used[i][j]=true;
                        used[i][j-1]=true;
                        used[i][j-2]=true;
                    }
                    else{
                        used[i][j]=true;
                        used[i-1][j]=true;
                        used[i-2][j]=true;
                    }
                    dp[i][j]++;
                    continue;
                }
            }
            if (i>=2){
                if (((vect[i][j]=='W'&&vect[i-1][j]=='G'&&vect[i-2][j]=='R')||(vect[i][j]=='R'&&vect[i-1][j]=='G'&&vect[i-2][j]=='W'))&&!used[i-1][j]&&!used[i-2][j]){
                    used[i][j]=true;
                    used[i-1][j]=true;
                    used[i-2][j]=true;
                    dp[i][j]++;
                    continue;
                }
            }
            if (j>=2){
                if (((vect[i][j]=='W'&&vect[i][j-1]=='G'&&vect[i][j-2]=='R')||(vect[i][j]=='R'&&vect[i][j-1]=='G'&&vect[i][j-2]=='W'))&&!used[i][j-1]&&!used[i][j-2]){
                    used[i][j]=true;
                    used[i][j-1]=true;
                    used[i][j-2]=true;
                    dp[i][j]++;
                    continue;
                }
            }
        }
    }
    cout<<dp[n-1][m-1]<<'\n';
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 336 KB Output is correct
2 Correct 1 ms 336 KB Output is correct
3 Correct 1 ms 336 KB Output is correct
4 Correct 1 ms 592 KB Output is correct
5 Correct 1 ms 336 KB Output is correct
6 Correct 1 ms 336 KB Output is correct
7 Correct 1 ms 336 KB Output is correct
8 Correct 1 ms 336 KB Output is correct
9 Correct 1 ms 336 KB Output is correct
10 Correct 1 ms 336 KB Output is correct
11 Correct 1 ms 336 KB Output is correct
12 Correct 1 ms 336 KB Output is correct
13 Incorrect 1 ms 336 KB Output isn't correct
14 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 336 KB Output is correct
2 Correct 1 ms 336 KB Output is correct
3 Correct 1 ms 336 KB Output is correct
4 Correct 1 ms 592 KB Output is correct
5 Correct 1 ms 336 KB Output is correct
6 Correct 1 ms 336 KB Output is correct
7 Correct 1 ms 336 KB Output is correct
8 Correct 1 ms 336 KB Output is correct
9 Correct 1 ms 336 KB Output is correct
10 Correct 1 ms 336 KB Output is correct
11 Correct 1 ms 336 KB Output is correct
12 Correct 1 ms 336 KB Output is correct
13 Incorrect 1 ms 336 KB Output isn't correct
14 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 336 KB Output is correct
2 Correct 1 ms 336 KB Output is correct
3 Correct 1 ms 336 KB Output is correct
4 Correct 1 ms 592 KB Output is correct
5 Correct 1 ms 336 KB Output is correct
6 Correct 1 ms 336 KB Output is correct
7 Correct 1 ms 336 KB Output is correct
8 Correct 1 ms 336 KB Output is correct
9 Correct 1 ms 336 KB Output is correct
10 Correct 1 ms 336 KB Output is correct
11 Correct 1 ms 336 KB Output is correct
12 Correct 1 ms 336 KB Output is correct
13 Incorrect 1 ms 336 KB Output isn't correct
14 Halted 0 ms 0 KB -