We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 7913eb3 commit ffe5881Copy full SHA for ffe5881
adamatrix.cpp
@@ -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
29
30
31
32
+ cout<<count<<"\n";
33
34
35
+ return 0;
36
+}
0 commit comments