import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
public class Main {
public static void main(String[] args) throws IOException {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
StringBuffer sb = new StringBuffer("");
int cases=Integer.parseInt(br.readLine());
for(int i=0;i<cases;i++){
String[]str=br.readLine().split("=");
int n=Integer.parseInt(str[1].trim());
long [][]arr=new long[n][n];
for(int j=0;j<n;j++){
String[] temp=br.readLine().split(" ");
for(int z=0;z<n;z++){
arr[j][z]=Long.parseLong(temp[z]);
}
}
long[][] temp=rotate180(arr);
sb.append("Test #").append((i+1)).append(": ");
if(check(arr, temp)){
sb.append("Symmetric.\n");
}else{
sb.append("Non-symmetric.\n");
}
}
System.out.print(sb);
}
static public long[][] rotate180(long[][] arr){
int x=arr.length,y=arr[0].length;
long[][]temp=new long[x][y];
for(int i=0;i<x;i++){
for(int j=0;j<y;j++){
temp[i][j]=arr[x-i-1][y-j-1];
}
}
return temp;
}
static boolean check(long[][]x,long[][]y){
for(int i=0;i<x.length;i++){
for(int j=0;j<y.length;j++){
if(x[i][j]!=y[i][j] ||x[i][j]<0||y[i][j]<0){
return false;
}
}
}
return true;
}
}
import java.io.IOException;
import java.io.InputStreamReader;
public class Main {
public static void main(String[] args) throws IOException {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
StringBuffer sb = new StringBuffer("");
int cases=Integer.parseInt(br.readLine());
for(int i=0;i<cases;i++){
String[]str=br.readLine().split("=");
int n=Integer.parseInt(str[1].trim());
long [][]arr=new long[n][n];
for(int j=0;j<n;j++){
String[] temp=br.readLine().split(" ");
for(int z=0;z<n;z++){
arr[j][z]=Long.parseLong(temp[z]);
}
}
long[][] temp=rotate180(arr);
sb.append("Test #").append((i+1)).append(": ");
if(check(arr, temp)){
sb.append("Symmetric.\n");
}else{
sb.append("Non-symmetric.\n");
}
}
System.out.print(sb);
}
static public long[][] rotate180(long[][] arr){
int x=arr.length,y=arr[0].length;
long[][]temp=new long[x][y];
for(int i=0;i<x;i++){
for(int j=0;j<y;j++){
temp[i][j]=arr[x-i-1][y-j-1];
}
}
return temp;
}
static boolean check(long[][]x,long[][]y){
for(int i=0;i<x.length;i++){
for(int j=0;j<y.length;j++){
if(x[i][j]!=y[i][j] ||x[i][j]<0||y[i][j]<0){
return false;
}
}
}
return true;
}
}
No comments:
Post a Comment