Submission #1286345

#TimeUsernameProblemLanguageResultExecution timeMemory
1286345juan_alejandroDango Maker (JOI18_dango_maker)C++20
13 / 100
2 ms588 KiB
#include <bits/stdc++.h>
#define endl '\n'
#define int long long
#pragma GCC optimize("O2")
using namespace std;
int n,m;
bool validotd(int &i,int &j,vector<vector<bool>> &vis,vector<string> &x)
{
    if(i+2>=n)return false;
    if(vis[i][j]||vis[i+1][j]||vis[i+2][j])return false;
    if(
        j-1>=0&&x[i+1][j-1]=='R'
        &&vis[i+1][j-1]==false
        &&x[i+1][j]=='G'&&vis[i+1][j]==false
        &&j+1<m
        &&x[i+1][j+1]=='W'&&vis[i+1][j+1]==false
        &&j-2>=0
        &&x[i+2][j-2]=='R'&&vis[i+2][j-2]==false
        &&x[i+2][j-1]=='G'&&vis[i+2][j-1]==false
        &&x[i+2][j]=='W'&&vis[i+2][j]==false
    )
        return false;
    return (x[i][j]=='R'&&x[i+1][j]=='G'&&x[i+2][j]=='W');
}
bool validolr(int &i,int &j,vector<vector<bool>> &vis,vector<string> &x)
{
    if(j+2>=m)return false;
    if(vis[i][j]||vis[i][j+1]||vis[i][j+2])return false;
    return (x[i][j]=='R'&&x[i][j+1]=='G'&&x[i][j+2]=='W');
}
int32_t main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    cout.precision(0);
    cout<<fixed;
    cin>>n>>m;
    vector<string> x(n);
    for (int i = 0; i < n; i++)
    {
        cin>>x[i];
    }
    vector<vector<bool>> vis(n,vector<bool>(m,false));
    int c=0;
    for (int i = 0; i < n; i++)
    {
        for (int j = 0; j < m; j++)
        {
            if(validotd(i,j,vis,x))
            {
                //cout<<i<<" "<<j<<" td"<<endl;
                c++;
                vis[i][j]=vis[i+1][j]=vis[i+2][j]=1;
            }
            if(validolr(i,j,vis,x))
            {
                //cout<<i<<" "<<j<<" lr"<<endl;
                c++;
                vis[i][j]=vis[i][j+1]=vis[i][j+2]=1;
            }
        }
    }
    cout<<c<<endl;
    /*
    WWRWWW
    WRGWWW
    RGWWWW

    WWRWWWW
    WRGWRGW
    WWWWWWw
    */
    return 0;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...