Untitled

mail@pastecode.io avatar
unknown
plain_text
7 months ago
1.5 kB
0
Indexable
Never
import java.util.Scanner;


public class Solution {

	static int N, count1, count2, count3;
	static int[][] map;
	static int[] visit;
	static Queue queue;
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc = new Scanner(System.in);

		int T = sc.nextInt();
		for (int t = 1; t <= T; t++) {
			N = sc.nextInt();
			map = new int[305][305];
			visit = new int[305];
			for(int i=0; i<N; i++){
				int count=0;
				for(int j=0; j<N ;j++){
					map[i][j] = sc.nextInt();
					if(map[i][j]==0){
						count++;
					}
					
				}
				if(count==N-1){
					count1++;
					count2++;
					visit[i] = 1;
				}
			}
			queue = new Queue(10000);
			
			for(int i=0; i<N; i++){
				if(visit[i] ==0){
					queue.push(i);
					visit[i] = 1;
					
				}
			}
			
		
		
		System.out.println(count2);
		}
		sc.close();
	}

}
class Queue {
	private int front, rear, capacity;
	private int queue[];

	Queue(int c) {
		front = rear = 0;
		capacity = c;
		queue = new int[capacity];
	};

	void push(int data) {
		queue[rear] = data;
		if (rear == capacity - 1)
			rear = -1;
		rear++;
	};

	int pop() {
		int res = queue[front];
		if (front == capacity - 1)
			front = -1;
		front++;
		return res;
	};

	void reset() {
		front = rear = 0;
	};

	boolean empty() {
		return front == rear;
	};

	int valueOf(int index) {
		return queue[index];
	};

	int length() {
		return rear - front;
	};
}