fork download
  1. public class BichromePainting
  2. {
  3.  
  4. int n;
  5. char[][] board;
  6.  
  7. public String isThatPossible(String[] _board, int k)
  8. {
  9. n = _board.length;
  10. board = new char[n][n];
  11. for(int i = 0; i < n; i++)
  12. for(int j = 0; j < n; j++)
  13. board[i][j] = _board[i].charAt(j);
  14. while(true)
  15. {
  16. boolean find = false;
  17. for(int i = 0; i+k <= n; i++)
  18. for(int j = 0; j+k <= n; j++)
  19. {
  20. boolean haveBlack = false;
  21. boolean haveWhite = false;
  22. for(int di = 0; di < k; di ++)
  23. for(int dj = 0; dj < k; dj ++)
  24. {
  25. if(board[i+di][j+dj] == 'W')
  26. haveWhite = true;
  27. if(board[i+di][j+dj] == 'B')
  28. haveBlack = true;
  29. }
  30. if(haveBlack != haveWhite)
  31. {
  32. find = true;
  33. for(int di = 0; di < k; di ++)
  34. for(int dj = 0; dj < k; dj ++)
  35. board[i+di][j+dj] = '?';
  36. }
  37. }
  38.  
  39. if(!find)
  40. break;
  41. }
  42. for(int i = 0; i < n; i++)
  43. for(int j = 0; j < n; j++)
  44. if(board[i][j] == 'B')
  45. return "Impossible";
  46. return "Possible";
  47. }
  48.  
  49. }
  50.  
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
Main.java:1: error: class BichromePainting is public, should be declared in a file named BichromePainting.java
public class BichromePainting
       ^
1 error
stdout
Standard output is empty