TOPIC

10% de erro

paulo asked 2 years ago

ja fiz varios casos de testes que deram certo e mesmo assim da 10% de erro

include

int main (void) { int n,i,vet[9],inst,p1,p2,p3,p4,q,kk,z,mat[9][9],j,cont,p; cont=0; inst=1; p1=0; p2=2; p3=0; p4=2; kk=1; z=0; q=9; scanf("%d",&n); while(n>0){ for(i=0;i<=8;i++){ vet[i]=0; } for(i=0;i<=8;i++){ for(j=0;j<=8;j++){ scanf("%d", &mat[i][j]); } } while(q>0){ cont+=1; for(i=p1;i<=p2;i++){ for(j=p3;j<=p4;j++){ vet[mat[i][j]-1]=vet[mat[i][j]-1]+1; } }

    for(i=0;i<=8;i++){
            if(vet[i]==kk){
                    z+=1;
                }
            }
    if(z==9){

                kk+=1;
                p3+=3;
                p4+=3;
        z=0;
        }   
        else{
                z=1;
                q=0;
        }
            if(cont==3 && z==0){
                p1+=3;
                p2+=3;
                p3=0;
                p4=2;
                cont=0;
        q-=3;
        }   
    }
    kk=1;
for(i=0;i<=8;i++){
                vet[i]=0;
}
if(z!=1){
    for(i=0;i<=8;i++){
            for(j=0;j<=8;j++){
                vet[mat[i][j]-1]=vet[mat[i][j]-1]+1;
            }
        for(p=0;p<=8;p++){
            if(vet[p]==kk){
                z+=1;
            }
        }
        if(z==9){
            z=0;
            kk+=1;
        }
        else{
            z=1;
            i=10;
        }       
    }
}   
kk=1;
for(i=0;i<=8;i++){
    vet[i]=0;
}
if(z!=1){
    for(j=0;j<=8;j++){
        for(i=0;i<=8;i++){
            vet[mat[i][j]-1]=vet[mat[i][j]-1]+1;
        }
        for(p=0;p<=8;p++){
                if(vet[p]==kk){
                z+=1;
            }
        }
        if(z==9){
            z=0;
            kk+=1;
        }
        else{
            z=1;
            i=10;

        }
    }
}   
    if(z==0){
    printf("Instancia %d\nSIM\n\n", inst);
}
else{
    printf("Instancia %d\nNAO\n\n", inst);
}
inst+=1;
    p1=0;
    p2=2;
    p3=0;
    p4=2;
    kk=1;
    n-=1;
q=9;
}

return 0;

}

This topic has not been answered yet. Be the first!

Remember not post solutions. Your post may be reviewed by our moderators.