답안 #139573

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
139573 2019-08-01T04:31:14 Z mirceaishere Tetris (COCI17_tetris) C++14
80 / 80
2 ms 504 KB
#include <iostream>
using namespace std;

int piesa1[4][4]={{1,1,0,0},{1,1,0,0},{0,0,0,0},{0,0,0,0}};

int piesa21[4][4]={{1,1,1,1},{0,0,0,0},{0,0,0,0},{0,0,0,0}};
int piesa22[4][4]={{1,0,0,0},{1,0,0,0},{1,0,0,0},{1,0,0,0}};

int piesa31[4][4]={{0,1,1,0},{1,1,0,0},{0,0,0,0},{0,0,0,0}};
int piesa32[4][4]={{1,0,0,0},{1,1,0,0},{0,1,0,0},{0,0,0,0}};

int piesa41[4][4]={{0,1,0,0},{1,1,0,0},{1,0,0,0},{0,0,0,0}};
int piesa42[4][4]={{1,1,0,0},{0,1,1,0},{0,0,0,0},{0,0,0,0}};

int piesa51[4][4]={{0,1,0,0},{1,1,0,0},{0,1,0,0},{0,0,0,0}};
int piesa52[4][4]={{0,1,0,0},{1,1,1,0},{0,0,0,0},{0,0,0,0}};
int piesa53[4][4]={{1,1,1,0},{0,1,0,0},{0,0,0,0},{0,0,0,0}};
int piesa54[4][4]={{1,0,0,0},{1,1,0,0},{1,0,0,0},{0,0,0,0}};




int n, m, i, j, imin, jmin, v[20][20], a[20][20], nr1, nr2, nr3, nr4, nr5, ii, jj, ok;
int piesacrt[6][6];
int di[4]={1, -1,  0,  0};
int dj[4]={0,  0,  1, -1};
char ch;

/// prima cifra = nr piesei
/// a doua cifra = modul in care este pusa

void fill(int ic, int jc, int ii, int jj){
    v[ic][jc]=0;
    piesacrt[ii][jj]=1;
    imin=min(ii, imin);
    jmin=min(jj, jmin);
    for(int d=0; d<4; d++){
        int iv=ic+di[d];
        int jv=jc+dj[d];
        if(a[ic][jc]==a[iv][jv] && v[iv][jv]){
            fill(iv, jv, ii+di[d], jj+dj[d]);
        }
    }
}

int main(){
    cin>>n>>m;
    for(i=1; i<=n; i++){
        for(j=1; j<=m; j++){
            cin>>ch;
            v[i][j]=ch-'a'+1;
            if(v[i][j]==-50){
                v[i][j]=0;
            }
            a[i][j]=v[i][j];
        }
    }
    for(i=1; i<=n; i++){
        for(j=1; j<=m; j++){
            if(v[i][j]!=0){
                imin=7;
                jmin=7;
                for(int aux1=0; aux1<6; aux1++){
                    for(int aux2=0; aux2<6; aux2++){
                        piesacrt[aux1][aux2]=0;
                    }
                }
                fill(i, j, 2, 2);
                ok=1;
                for(ii=0; ii<4; ii++){
                    for(jj=0; jj<4; jj++){
                        if(piesacrt[imin+ii][jmin+jj]!=piesa1[ii][jj]){
                            ok=0;
                            break;
                        }
                    }
                }
                if(ok==1){
                    nr1++;
                }
                ok=1;
                for(ii=0; ii<4; ii++){
                    for(jj=0; jj<4; jj++){
                        if(piesacrt[imin+ii][jmin+jj]!=piesa21[ii][jj]){
                            ok=0;
                            break;
                        }
                    }
                }
                if(ok==1){
                    nr2++;
                }
                ok=1;
                for(int ii=0; ii<4; ii++){
                    for(int jj=0; jj<4; jj++){
                        if(piesacrt[imin+ii][jmin+jj]!=piesa22[ii][jj]){
                            ok=0;
                            break;
                        }
                    }
                }
                if(ok==1){
                    nr2++;
                }
                ok=1;
                for(ii=0; ii<4; ii++){
                    for(jj=0; jj<4; jj++){
                        if(piesacrt[imin+ii][jmin+jj]!=piesa31[ii][jj]){
                            ok=0;
                            break;
                        }
                    }
                }
                if(ok==1){
                    nr3++;
                }
                ok=1;
                for(ii=0; ii<4; ii++){
                    for(jj=0; jj<4; jj++){
                        if(piesacrt[imin+ii][jmin+jj]!=piesa32[ii][jj]){
                            ok=0;
                            break;
                        }
                    }
                }
                if(ok==1){
                    nr3++;
                }

                ok=1;
                for(ii=0; ii<4; ii++){
                    for(jj=0; jj<4; jj++){
                        if(piesacrt[imin+ii][jmin+jj]!=piesa41[ii][jj]){
                            ok=0;
                            break;
                        }
                    }
                }
                if(ok==1){
                    nr4++;
                }
                ok=1;
                for(ii=0; ii<4; ii++){
                    for(jj=0; jj<4; jj++){
                        if(piesacrt[imin+ii][jmin+jj]!=piesa42[ii][jj]){
                            ok=0;
                            break;
                        }
                    }
                }
                if(ok==1){
                    nr4++;
                }
                ok=1;
                for(ii=0; ii<4; ii++){
                    for(jj=0; jj<4; jj++){
                        if(piesacrt[imin+ii][jmin+jj]!=piesa51[ii][jj]){
                            ok=0;
                            break;
                        }
                    }
                }
                if(ok==1){
                    nr5++;
                }
                ok=1;
                for(int ii=0; ii<4; ii++){
                    for(int jj=0; jj<4; jj++){
                        if(piesacrt[imin+ii][jmin+jj]!=piesa52[ii][jj]){
                            ok=0;
                            break;
                        }
                    }
                }
                if(ok==1){
                    nr5++;
                }
                ok=1;
                for(ii=0; ii<4; ii++){
                    for(jj=0; jj<4; jj++){
                        if(piesacrt[imin+ii][jmin+jj]!=piesa53[ii][jj]){
                            ok=0;
                            break;
                        }
                    }
                }
                if(ok==1){
                    nr5++;
                }
                ok=1;
                for(ii=0; ii<4; ii++){
                    for(jj=0; jj<4; jj++){
                        if(piesacrt[imin+ii][jmin+jj]!=piesa54[ii][jj]){
                            ok=0;
                            break;
                        }
                    }
                }
                if(ok==1){
                    nr5++;
                }
            }
        }
    }
    cout<<nr1<<"\n"<<nr2<<"\n"<<nr3<<"\n"<<nr4<<"\n"<<nr5;
}


# 결과 실행 시간 메모리 Grader output
1 Correct 2 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 2 ms 256 KB Output is correct
5 Correct 2 ms 504 KB Output is correct
6 Correct 2 ms 376 KB Output is correct
7 Correct 2 ms 256 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