General
 
 
# Author Problem Lang Verdict Time Memory Sent Judged  
92467452 Practice:
abhishekumar_1401
1330B - 40 GNU C++14 Wrong answer on test 2 31 ms 144 KB 2020-09-11 06:41:23 2020-09-11 06:41:23
 
 
→ Source
#include <bits/stdc++.h>
using namespace std;
 
#define ll long long
#define ull unsigned long long
#define ld long double
 
#define mod 1000000007
vector<ll> res;

void F1(vector<ll> &vec, ll max_element)
{
    int f = 0, n = vec.size();
    for(int i = 0; i < max_element; i++)
    {
       if(vec[i] > max_element)
       {
           f = 1;
           break;
       }
   }
   if(f == 0) 
   {
       set<ll> s;
       for(int i = 0; i < max_element; i++) 
            s.insert(vec[i]);
       
       if(s.size() == max_element)
       {
           ll x = n - max_element;
           for(int i = max_element; i < n; i++)
           {
               if(vec[i] > x) 
               {
                   f = 1;
                   break;
               }
           }
           if(f == 0)
           {
               s.clear();
               for(int i = max_element; i < n; i++) 
                    s.insert(vec[i]);
                
                if(s.size() == x)
                {
                    res.push_back(max_element);
                    res.push_back(x);
                }
           }
       }
   }
}

void F2(vector<ll> &vec, ll max_element)
{
    int f = 0, n = vec.size();
    for(int i = n-1; i >= n - max_element; i--)
    {
       if(vec[i] > max_element)
       {
           f = 1;
           break;
       }
   }
   if(f == 0) 
   {
       set<ll> s;
       for(int i = n-1; i >= n - max_element; i--) 
            s.insert(vec[i]);
       
       if(s.size() == max_element)
       {
           ll x = n - max_element;
           for(int i = n- max_element - 1; i >= 0; i--)
           {
               if(vec[i] > x) 
               {
                   f = 1;
                   break;
               }
           }
           
           if(f == 0)
           {
               s.clear();
               
               for(int i = n-max_element-1; i >= 0; i--) 
                    s.insert(vec[i]);
                
                if(s.size() == x)
                {
                    res.push_back(x);
                    res.push_back(max_element);
                }
           }
       }
   }
}

int32_t main()
{
    ios::sync_with_stdio(0), cin.tie(0);
    
    ll t = 1;
    cin >> t;
    
    while(t--)
    {
        ll n;
        cin >> n;
        
       vector<ll> vec(n);
       
       ll max_element = 0;
       for(int i = 0; i < n; i++) 
       {
           cin >> vec[i];
           max_element = max(vec[i], max_element); 
       }
       F1(vec, max_element);
       F2(vec, max_element);
       
       cout<<res.size()/2<<"\n";
       for(int i = 0; i < res.size(); i=i+2)
       {
           cout<<res[i]<<" "<<res[i+1]<<"\n";
       }
       res.clear();
    }
    return 0;
}
 
 
?
Time: ? ms, memory: ? KB
Verdict: ?
Input
?
Participant's output
?
Jury's answer
?
Checker comment
?
Diagnostics
?
Click to see test details