Advertisement
Guest User

Untitled

a guest
Jul 17th, 2019
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.92 KB | None | 0 0
  1. #include <cstdio>
  2.  
  3. int n;
  4. int a[1005][1005];
  5. int w,h;
  6.  
  7. int main(){
  8. scanf("%d",&n);
  9. int i,j;
  10. for (i=1;i<=n;i++){
  11. for (j=1;j<=n;j++){
  12. scanf("%d",&a[i][j]);
  13. }
  14. }
  15. for (i=1;i<=n;i++){
  16. for (j=1;j<=n;j++){
  17. if( a[i][j] == 0){
  18. w = 1;
  19. h = 1;
  20. int pos = j;
  21. for(j=j+1;j<=n;j++){
  22. if(a[i][j] == 0)
  23. w++;
  24. else
  25. break;
  26. }
  27. for(j=i+1;j<=n;j++){
  28. if( a[j][pos] == 0)
  29. h++;
  30. else
  31. break;
  32. }
  33.  
  34. int ans = w*h -( (w-2)*2+(h-2)*2+4);
  35. printf("%d\n",ans);
  36.  
  37. return 0;
  38. }
  39. }
  40. }
  41. printf("0");
  42. return 0;
  43. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement