Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- int main(){
- int n, corr = 0;
- scanf("%d", &n);
- for(int tc=1; tc<=n; tc++){
- int board[9][9];
- bool correct = true;
- for(int i=0; i<9 ;i++)
- for(int j=0; j<9; j++)
- scanf("%d", &board[i][j]);
- for(int i=0; i<9 && correct;i++){
- bool flag[10] = {0};
- for(int j=0; j<9; j++){
- if(flag[board[i][j]]){
- correct = false;
- break;
- }else{
- flag[board[i][j]] = true;
- }
- }
- }
- for(int i=0; i<9 && correct;i++){
- bool flag[10] = {0};
- for(int j=0; j<9; j++){
- if(flag[board[j][i]]){
- correct = false;
- break;
- }else{
- flag[board[j][i]] = true;
- }
- }
- }
- for(int i=0; i<9; i+=3){
- for(int j=0; j<9; j+=3){
- bool flag[10] = {0};
- for(int k=i; k<i+3; k++){
- for(int l=j; l<j+3; l++){
- if(flag[board[k][l]]){
- correct = false;
- break;
- }else{
- flag[board[k][l]] = true;
- }
- }
- }
- }
- }
- if(correct){
- corr++;
- printf("Case #%d: TRUE\n", tc);
- }else{
- printf("Case #%d: FALSE\n", tc);
- }
- }
- printf("%.2f%%\n", (double)corr*100/n);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement