Question: Give a square number array with a side length of N * n, and then ask whether there is a heavy number of values in each row, column, and array. Let's take a look at the two examples.
Question: What do you want me to do ?...... If not, how much water should you have. Directly code one byte and one byte.
Code:
#include <cstdio>#include <cstring>using namespace std;#define N 105int map[N][N],visit[N],n,m;int main(){//freopen("test.in","r",stdin);int i,j,flag=1,_i,_j;scanf("%d",&n);m=n*n;for(i=1;i<=m;i++)for(j=1;j<=m;j++)scanf("%d",&map[i][j]);for(i=1;i<=m;i++){memset(visit,0,sizeof(visit));for(j=1;j<=m;j++)if(visit[map[i][j]]){puts("INCORRECT");return 0;}else if(map[i][j])visit[map[i][j]]=1;memset(visit,0,sizeof(visit));for(j=1;j<=m;j++)if(visit[map[j][i]]){puts("INCORRECT");return 0;}else if(map[j][i])visit[map[j][i]]=1;}for(i=0;i<n;i++)for(j=0;j<n;j++){memset(visit,0,sizeof(visit));for(_i=1;_i<=n;_i++)for(_j=1;_j<=n;_j++){if(visit[map[i*n+_i][j*n+_j]]){puts("INCORRECT");return 0;}else if(map[i*n+_i][j*n+_j])visit[map[i*n+_i][j*n+_j]]=1;}}puts("CORRECT");return 0;}
[Poj3435] Sudoku checker. Note: This is not a Sudoku !!!!