Skip to content

Commit

Permalink
Create adamatrix.cpp
Browse files Browse the repository at this point in the history
  • Loading branch information
sans242 authored Oct 22, 2020
1 parent 7913eb3 commit ffe5881
Showing 1 changed file with 36 additions and 0 deletions.
36 changes: 36 additions & 0 deletions adamatrix.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
#include <iostream>
using namespace std;

int main() {
// your code goes here
int t;
cin>>t;

while(t--){
int n;
cin>>n;

int arr[n][n];
for(int i=0;i<n;i++){
for(int j=0;j<n;j++){
cin>>arr[i][j];
}
}
int count=0;
for(int i=n-1;i>=0;i--){
if(count%2==0){
if(arr[0][i]!=i+1){
count++;
}
}
if(count%2==1){
if(arr[i][0]!=i+1){
count++;
}
}
}
cout<<count<<"\n";

}
return 0;
}

0 comments on commit ffe5881

Please sign in to comment.