Submission #138878

# Submission time Handle Problem Language Result Execution time Memory
138878 2019-07-30T17:07:42 Z vladciuperceanu Tetris (COCI17_tetris) C++14
80 / 80
2 ms 380 KB
#include <iostream>

using namespace std;

int n,m,i,j,sol[5];
char a[15][15];

struct figura
{
    int n;
    int m;
    int mat[4][4];
};

struct tip
{
    int numar;
    figura fig[5];
};

tip f[5] =
{
    {
        1,
        {
            {
                2, 2,
                {
                    {1, 1, 0, 0},
                    {1, 1, 0, 0},
                    {0, 0, 0, 0},
                    {0, 0, 0, 0}
                }
            }
        }
    },
    {
        2,
        {
            {
                1, 4,
                {
                    {1, 1, 1, 1},
                    {0, 0, 0, 0},
                    {0, 0, 0, 0},
                    {0, 0, 0, 0}
                }
            },
            {
                4, 1,
                {
                    {1, 0, 0, 0},
                    {1, 0, 0, 0},
                    {1, 0, 0, 0},
                    {1, 0, 0, 0}
                }
            }
        }
    },
    {
        2,
        {
            {
                2, 3,
                {
                    {0, 1, 1, 0},
                    {1, 1, 0, 0},
                    {0, 0, 0, 0},
                    {0, 0, 0, 0}
                }
            },
            {
                3, 2,
                {
                    {1, 0, 0, 0},
                    {1, 1, 0, 0},
                    {0, 1, 0, 0},
                    {0, 0, 0, 0}
                }
            }
        }
    },
    {
        2,
        {
            {
                2, 3,
                {
                    {1, 1, 0, 0},
                    {0, 1, 1, 0},
                    {0, 0, 0, 0},
                    {0, 0, 0, 0}
                }
            },
            {
                3, 2,
                {
                    {0, 1, 0, 0},
                    {1, 1, 0, 0},
                    {1, 0, 0, 0},
                    {0, 0, 0, 0}
                }
            }
        }
    },
    {
        4,
        {
            {
                2, 3,
                {
                    {0, 1, 0, 0},
                    {1, 1, 1, 0},
                    {0, 0, 0, 0},
                    {0, 0, 0, 0}
                }
            },
            {
                3, 2,
                {
                    {0, 1, 0, 0},
                    {1, 1, 0, 0},
                    {0, 1, 0, 0},
                    {0, 0, 0, 0}
                }
            },
            {
                2, 3,
                {
                    {1, 1, 1, 0},
                    {0, 1, 0, 0},
                    {0, 0, 0, 0},
                    {0, 0, 0, 0}
                }
            },
            {
                3, 2,
                {
                    {1, 0, 0, 0},
                    {1, 1, 0, 0},
                    {1, 0, 0, 0},
                    {0, 0, 0, 0}
                }
            }
        }
    }
};

int main()
{
    cin >> n >> m;
    for (i=0; i<n; i++)
        for (j=0; j<m; j++)
            cin >> a[i][j];
    for (int tipar=0; tipar<5; tipar++)
        for (int rot=0; rot<f[tipar].numar; rot++)
        {
            int lin = f[tipar].fig[rot].n;
            int col = f[tipar].fig[rot].m;
            for (i=0; i+lin-1<n; i++)
                for (j=0; j+col-1<m; j++)
                    for (char litera='a'; litera<='z'; litera++)
                    {
                        int ok = 0;
                        for (int ii=0; ii<lin; ii++)
                            for (int jj=0; jj<col; jj++)
                                if ((f[tipar].fig[rot].mat[ii][jj] == 0 && a[i+ii][j+jj] == litera) || (f[tipar].fig[rot].mat[ii][jj] == 1 && a[i+ii][j+jj] != litera))
                                    ok = 1;
                        if (ok == 0)
                            sol[tipar]++;
                    }
        }
    for (i=0; i<5; i++)
        cout << sol[i] << "\n";
    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 256 KB Output is correct
3 Correct 2 ms 248 KB Output is correct
4 Correct 2 ms 256 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
6 Correct 2 ms 376 KB Output is correct
7 Correct 2 ms 380 KB Output is correct
8 Correct 2 ms 376 KB Output is correct
9 Correct 2 ms 376 KB Output is correct
10 Correct 2 ms 256 KB Output is correct