Submission #139396

# Submission time Handle Problem Language Result Execution time Memory
139396 2019-07-31T15:57:58 Z mariadinca Tetris (COCI17_tetris) C++14
80 / 80
5 ms 376 KB
#include <iostream>

using namespace std;

int n, m, i, j, h, f, w, t, sol[6];
char x[12][12];

struct figura{
    int ne;
    int me;
    int v[4][4];
};

struct tip{
    int rotatii;
    figura fig[4];
};

tip s[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, {{1, 0, 0, 0}, {1, 1, 0, 0}, {1, 0, 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, {{0, 1, 0, 0}, {1, 1, 0, 0}, {0, 1, 0, 0}, {0, 0, 0, 0}}}}

    }

};

int main(){
    cin>>n>>m;
    for(i=1;i<=n;i++)
        for(j=1;j<=m;j++)
            cin>>x[i][j];
    for(i=1;i<=n;i++)
        for(j=1;j<=m;j++){
            for(t=0;t<5;t++){
                for(w=0;w<s[t].rotatii;w++){
                    int lin = s[t].fig[w].ne;
                    int col = s[t].fig[w].me;
                    for(char lit = 'a';lit <= 'z';lit++){
                        int ok = 1;
                        for(h=i;h<=i+lin-1;h++)
                            for(f=j;f<=j+col-1;f++)
                                if(!((x[h][f] == lit && s[t].fig[w].v[h-i][f-j] == 1) || (x[h][f] != lit && s[t].fig[w].v[h-i][f-j] == 0))){
                                    h = i+lin;
                                    ok = 0;
                                    break;
                                }
                        if(ok == 1)
                            sol[t]++;
                    }
                }
            }
        }
    for(i=0;i<5;i++)
        cout<<sol[i]<<endl;
    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 3 ms 256 KB Output is correct
2 Correct 2 ms 256 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 5 ms 376 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 376 KB Output is correct
8 Correct 2 ms 256 KB Output is correct
9 Correct 2 ms 376 KB Output is correct
10 Correct 2 ms 376 KB Output is correct