Skip to content

Commit ffe5881

Browse files
authored
Create adamatrix.cpp
1 parent 7913eb3 commit ffe5881

File tree

1 file changed

+36
-0
lines changed

1 file changed

+36
-0
lines changed

adamatrix.cpp

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
#include <iostream>
2+
using namespace std;
3+
4+
int main() {
5+
// your code goes here
6+
int t;
7+
cin>>t;
8+
9+
while(t--){
10+
int n;
11+
cin>>n;
12+
13+
int arr[n][n];
14+
for(int i=0;i<n;i++){
15+
for(int j=0;j<n;j++){
16+
cin>>arr[i][j];
17+
}
18+
}
19+
int count=0;
20+
for(int i=n-1;i>=0;i--){
21+
if(count%2==0){
22+
if(arr[0][i]!=i+1){
23+
count++;
24+
}
25+
}
26+
if(count%2==1){
27+
if(arr[i][0]!=i+1){
28+
count++;
29+
}
30+
}
31+
}
32+
cout<<count<<"\n";
33+
34+
}
35+
return 0;
36+
}

0 commit comments

Comments
 (0)