제출 #564757

#제출 시각아이디문제언어결과실행 시간메모리
564757groshiDango Maker (JOI18_dango_maker)C++17
100 / 100
248 ms20868 KiB
#include<iostream>

using namespace std;
char t[4000][4000];
bool czy_pion(int x,int y)
{
    return (t[x][y]=='G' && t[x-1][y]=='R' && t[x+1][y]=='W');
}
bool czy_poz(int x,int y)
{
    return (t[x][y]=='G' && t[x][y-1]=='R' && t[x][y+1]=='W');
}
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int n,m;
    cin>>n>>m;
    for(int i=1;i<=n;i++)
        for(int j=1;j<=m;j++)
            cin>>t[i][j];
    int wynik=0;
    for(int i=1;i<=n+m-1;i++)
    {
        int x=min(n,i);
        int y=max(1,i-n+1);
        int teraz=0,wys_pion=0,wys_poz=0,ost=0;
        while(x>=1 && y<=m)
        {
            bool pion=0,poz=0;
            pion=czy_pion(x,y);
            poz=czy_poz(x,y);
            if(pion)
                wys_pion=max(ost,wys_pion)+1;
            if(poz)
                wys_poz=max(ost,wys_poz)+1;
            ost=teraz;
            teraz=max(wys_pion,wys_poz);
            x--;
            y++;
        }
        wynik+=teraz;
    }
    cout<<wynik;
    return 0;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...