fork download
  1. #include <iostream>
  2. using namespace std;
  3. void divCon(int x, int y, int size);
  4. int c[3]; int n;
  5. int map[3000][3000];
  6.  
  7. void func(int x, int y, int size){
  8. int paper = map[x][y];
  9. int check = false;
  10. for(int i=x; i<x+size; i++){
  11. for(int j=y; j<y+size; j++){
  12. if( paper != map[i][j] ){
  13. divCon(x, y, size);
  14. check = true;
  15. break;
  16. }
  17. }
  18. if(check == true) break;
  19. }
  20. if(check == false) c[paper+1]++;
  21. }
  22.  
  23. void divCon(int x, int y, int size){
  24. size = size/3;
  25. func(x, y, size);
  26. func(x, y+size, size);
  27. func(x, y+size+size, size);
  28.  
  29. func(x+size, y, size);
  30. func(x+size, y+size, size);
  31. func(x+size, y+size+size, size);
  32.  
  33. func(x+size+size, y, size);
  34. func(x+size+size, y+size, size);
  35. func(x+size+size, y+size+size, size);
  36. }
  37.  
  38. int main(){
  39. ios::sync_with_stdio(0);
  40. cin.tie(0);
  41.  
  42. cin >> n;
  43.  
  44. for (int i = 0; i < n; ++i) {
  45. for (int j = 0; j < n; ++j) {
  46. cin >> map[i][j];
  47. }
  48. }
  49.  
  50. divCon(0, 0, n);
  51. cout << c[0] << '\n' << c[1] << '\n' << c[2];
  52. }
Success #stdin #stdout 0s 4452KB
stdin
1
1
stdout
0
0
9