-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathb.cpp
More file actions
35 lines (32 loc) · 730 Bytes
/
b.cpp
File metadata and controls
35 lines (32 loc) · 730 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
#include <bits/stdc++.h>
#define endl '\n'
#define eat cin
#define moo cout
#define int long long
using namespace std;
int T, N, a[50];
int32_t main(){
eat.tie(0) -> sync_with_stdio(0);
eat >> T;
while(T--){
eat >> N;
for(int i = 0; i < N; i++) eat >> a[i];
bool sorted = true;
for(int i = 1; i < N; i++){
if(a[i] != a[i-1] + 1) sorted = false;
}
if(sorted){
moo << 0 << endl;
continue;
}
if(a[0] == 1 || a[N-1] == N){
moo << 1 << endl;
continue;
}
if(a[0] == N && a[N-1] == 1){
moo << 3 << endl;
continue;
}
moo << 2 << endl;
}
}