Submission #510193

# Submission time Handle Problem Language Result Execution time Memory
510193 2022-01-14T18:53:07 Z Rasoul006 Tetris (COCI17_tetris) C++17
80 / 80
1 ms 204 KB
#include <bits/stdc++.h>

#define endl "\n" ;

typedef long long ll ;

using namespace std;

char a[19][19];

ll n,m,ans1,ans2,ans3,ans4,ans5;

int main()
{
    ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);

    cin>>n>>m;

    for (int i=0 ; i<n ; i++)
    {
        for (int j=0 ; j<m ; j++)
        {
            cin>>a[i][j];
        }
    }

    for (int i=0 ; i<n ; i++)
    {
        for (int j=0 ; j<m ; j++)
        {
            if (a[i][j]==a[i+1][j] && a[i][j] == a[i][j+1] && a[i][j] == a[i+1][j+1] && a[i][j] != '.')
                    ans1++;
        }
    }

    for (int i=0 ; i<n ; i++)
    {
        for (int j=0 ; j<m ; j++)
        {
            if (a[i][j]==a[i+1][j]&&a[i][j]==a[i+2][j]&&a[i][j]==a[i+3][j]&& a[i][j] != '.')
                    ans2++;

             if (a[i][j]==a[i][j+1]&&a[i][j]==a[i][j+2]&&a[i][j]==a[i][j+3] && a[i][j] != '.')
                    ans2++;
        }
    }

    for (int i=0 ; i<n ; i++)
    {
        for (int j=0 ; j<m ; j++)
        {
            if (a[i][j] == a[i+1][j] && a[i][j] == a[i+1][j-1] && a[i][j] == a[i][j+1] && a[i][j] != '.')
                ans3++;

            if (a[i][j] == a[i-1][j] && a[i][j] == a[i][j+1] && a[i][j] == a[i+1][j+1] && a[i][j] != '.')
                ans3++;
        }
    }

    for (int i=0 ; i<n ; i++)
    {
        for (int j=0 ; j<m ; j++)
        {
            if (a[i][j] == a[i][j-1] && a[i][j] == a[i+1][j] && a[i][j] == a[i+1][j+1] && a[i][j] != '.')
                ans4++;

            if (a[i][j] == a[i][j-1] && a[i][j] == a[i-1][j] && a[i][j] == a[i+1][j-1] && a[i][j] != '.')
                ans4++;
        }
    }



    for (int i=0 ; i<n ; i++)
    {
        for (int j=0 ; j<m ; j++)
        {
            if (a[i][j]==a[i][j+1] && a[i][j] == a[i-1][j+1] && a[i][j] == a[i+1][j+1] && a[i][j] != '.')
                ans5++;
            if (a[i][j]==a[i+1][j] && a[i][j]==a[i-1][j] && a[i][j] == a[i][j+1] && a[i][j] != '.')
                ans5++;
            if (a[i][j] == a[i-1][j] && a[i][j] == a[i][j+1] && a[i][j] == a[i][j-1] && a[i][j] != '.')
                ans5++;
            if (a[i][j]== a[i+1][j] && a[i][j] == a[i][j-1] && a[i][j] == a[i][j+1] && a[i][j] != '.')
                ans5++;
        }
    }

    cout<<ans1<<"\n"<<ans2<<"\n"<<ans3<<"\n"<<ans4<<"\n"<<ans5<<endl;

    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 0 ms 204 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 1 ms 204 KB Output is correct
6 Correct 0 ms 204 KB Output is correct
7 Correct 0 ms 204 KB Output is correct
8 Correct 0 ms 204 KB Output is correct
9 Correct 0 ms 204 KB Output is correct
10 Correct 0 ms 204 KB Output is correct