Cod sursa(job #2595297)

Utilizator tifui.alexandruTifui Ioan Alexandru tifui.alexandru Data 7 aprilie 2020 15:23:07
Problema Sortare prin comparare Scor 0
Compilator cpp-64 Status done
Runda Arhiva educationala Marime 1.16 kb
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define pii pair <int,int>
#define mp make_pair
#define pb push_back
#define x first
#define y second

using namespace std;

const int Nmax = 2e5 + 5;
int v[Nmax];

unordered_set <int> vis;

bool check(int p, int q) {
    vis.clear();
    for (int i = p; i <= q; ++i)
        vis.insert(v[i]);
    for (int i = 1; i <= q - p + 1; ++i)
        if (vis.find(i) == vis.end())
            return false;
    return true;
}

int main(){
    ios_base :: sync_with_stdio(false);
    cin.tie(nullptr);
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);

    int t, n;
    cin >> t;
    vector <int> cnd;
    vector <pii> ans;
    while (t--) {
        cin >> n;
        for (int i = 1; i <= n; ++i)
            cin >> v[i];
        int mx = *max_element(v + 1, v + n + 1);
        if (check(1, mx) and check(mx + 1, n))
            ans.pb({mx, n - mx});
        if (check(1, n - mx) and check(n - mx + 1, n))
            ans.pb({n - mx, mx});
        cout << ans.size() << '\n';
        for (auto it : ans)
            cout << it.x << ' ' << it.y << '\n';
        ans.clear();
    }

    return 0;
}