Do not know why WA, should be not understand test instructions ...
I understand that. If there is a non-0 point around a 0 point and only one is filled in that non 0 point, otherwise remain 0.
Or WA?
#include <iostream> #include <cstring> using namespace std; int map[202][202],tmap[202][
202];
int isval (int x,int y) {int count=0,temp;
if (Map[x+1][y]) {count++;
Temp=map[x+1][y];
} if (Map[x-1][y]) {count++;
Temp=map[x-1][y];
} if (Map[x][y+1]) {count++;
TEMP=MAP[X][Y+1];
} if (Map[x][y-1]) {count++;
TEMP=MAP[X][Y-1];
} if (count==1) return temp;
else return 0;
} int main () {int icase;
cin>>icase;
while (icase--) {memset (map,0,sizeof (map));
memset (tmap,0,sizeof (TMap));
int num;
cin>>num;
for (int i=1;i<=num;i++) for (int j=1;j<=num;j++) {cin>>map[i][j];
TMAP[I][J]=MAP[I][J];
} for (int i=1;i<=num;i++) for (int j=1;j<=num;j++) {if (!map[i][j]) tmap[i][j]=isval (I,J);
} for (int i=1;i<=num;i++) {for (int j=1;j<=num;j++) cout<<tmap[i][j]<< ";
cout<<endl;
} cout<<endl;
} return 0; }