Codeforces C. Omkar and Baseball (Round #655 Div.2)

Codeforces C. Omkar and Baseball (Round #655 Div.2)_第1张图片

#include 
#include 
#include 
#include 
#include 
#include 
#include 
using namespace std;
#define INF 0x3f3f3f3f
const int maxn = 150;
int t, n;
int a[maxn];
int main(){
    cin >> t;
    while (t--) {
        cin >> n;
        int cnt = 0;
        for (int i = 1; i <= n; i++) {
            cin >> a[i];
            if (a[i] != i && a[i - 1] == i - 1) cnt++;
        }
        if (!cnt) cout << 0 << endl;
        else if (cnt == 1) cout << 1 << endl;
        else cout << 2 << endl;

    }
    return 0;
}

你可能感兴趣的:(Codeforces C. Omkar and Baseball (Round #655 Div.2))