#include<stdio.h> intmain() { int arr1[15]; int n; scanf("%d", &n); int flag = 1; int k = 0; for (k = 0; k < n; k++) { flag = 1; int m; scanf("%d", &m); int i = 0, j = 0; int arr[11][11];
for (i = 0; i < m; i++) { for (j = 0; j < m; j++) { scanf("%d", &arr[i][j]); } } for (i = 0; i < m; i++) { for (j = 0; j < m; j++) { if (i > j&&arr[i][j] != 0) { flag = 0; break; } } } if (flag) { arr1[k] = 1; } else { arr1[k]=0; } } int i = 0; for (i = 0; i < n; i++) { if (arr1[i] == 1) printf("YES\n"); else printf("NO\n"); }
#include<stdio.h> intmain() { int n; scanf("%d", &n); int m; int i = 0; int j = 0;
while (n--) { int count = 0; scanf("%d", &m); int arr[100][100] = { 0 };
for (i = 0; i < m; i++) { for (j = 0; j < m; j++) { scanf("%d ", &arr[i][j]); } } for (i = 1; i < m; i++) { for (j = 0; j < i; j++) { if (arr[i][j] == 0) { count++; } } } int sum = (m * (m - 1)) / 2; if (sum == count) { printf("YES\n"); } else { printf("NO\n"); } } } return0; }