[ create a new paste ] login | about

Link: http://codepad.org/VydsZS53    [ raw code | output | fork ]

hoaithu.melody - C++, pasted on May 31:
//Cutting paper
import java.util.Scanner;

public class Solution {
 static int countT;
 static int countX;
 
 public static void main(String[] args)  {
  //System.setIn(new FileInputStream("input1.txt"));
  Scanner sc = new Scanner(System.in);
  int T = sc.nextInt();
  for (int t = 1; t <= T; t++) {
   int n = sc.nextInt();
   int[][] a = new int[n][n];
   for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
     a[i][j] = sc.nextInt();
    }
   }
   countT = countX = 0;
   countTrang(a, 0, 0, n);
   System.out.println("Case #"+t);
   System.out.print(countT+" ");
   System.out.println(countX);
   
  }
 }

 static void countTrang(int[][] a, int x, int y, int s) {
  if (s == 0)
   return;

  if (checkTrang(a, x, y, s)) {
   
   countT++;
  } else if (checkXanh(a, x, y, s)) {
   countX++;
  } else {
   countTrang(a, x, y, s / 2);
   countTrang(a, x + s / 2, y, s / 2);
   countTrang(a, x, y + s / 2, s / 2);
   countTrang(a, x + s / 2, y + s / 2, s / 2);
  }
 }

 static boolean checkTrang(int[][] a, int x, int y, int s) {
  for (int i = x; i < x + s; i++) {
   for (int j = y; j < y + s; j++) {
    if (a[i][j] != 0)
     return false;
   }
  }
  return true;
 }

 static boolean checkXanh(int[][] a, int x, int y, int s) {
  for (int i = x; i < x + s; i++) {
   for (int j = y; j < y + s; j++) {
    if (a[i][j] != 1)
     return false;
   }
  }
  return true;
 }

}


Output:
1
2
Line 2: error: 'import' does not name a type
compilation terminated due to -Wfatal-errors.


Create a new paste based on this one


Comments: