General
 
 
# Author Problem Lang Verdict Time Memory Sent Judged  
75483684 Practice:
Arimas
1330B - 40 GNU C++17 Accepted 405 ms 36268 KB 2020-04-04 15:14:48 2020-04-04 15:14:48
 
 
→ Source
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define pll pair<ll,ll>
#define ll long long
#define lli long long int
#define ull unsigned long long
#define ld long double
#define pii pair<int,int>
#define lower_boundIDX(x,val) lower_bound(all(x),val)-x.begin()
#define upper_boundIDX(x,val) upper_bound(all(x),val)-x.begin()
#define mem(a,val)  memset(a,val,sizeof(a))
#define all(x) x.begin(),x.end()
#define Ibit(x)  __builtin_popcount(x)
#define Obit(x)  __builtin_ctz(x)
#define minHeap priority_queue<int,vector<int> ,greater<int>>
#define maxHeap priority_queue<int>
#define need_for_speed ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
const int  MOD = 1000000007;
const int MAX  = 2e5+7;
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
#pragma GCC optimize("Ofast")
 
signed main() {
  need_for_speed;
  int t;
  cin>>t;
  while(t-->0)
  {
    int ans = 0,flag = 0;
    map<int,int> distinct1,distinct2;
    map<int,int> track,track2;
    int n; cin>>n;
    vector<int> vi(n,0),prefix(n, 0),suffix(n, 0);
    for(int i=0;i<n;i++)
    {
      cin>>vi[i];
      if(!flag)
      {
        if(track[vi[i]]!=1) { track[vi[i]]=1; distinct1[i] = 1; }
        else{ flag = 1; distinct1[i] = 0; }
      }
      else distinct1[i] = 0;
    }
    //for future refreances::
    prefix[0] = vi[0];
    suffix[0] = vi[n-1];
    for(int i=1;i<n;i++) prefix[i]+=(prefix[i-1] + vi[i]);
    for(int i=1;i<n;i++) suffix[i]+=(suffix[i-1] + vi[n-1-i]);
    flag = 0;
    for(int i=n-1;i>=0;i--)
    {
      if(!flag)
      {
        if(track2[vi[i]]!=1){ track2[vi[i]]=1; distinct2[n-i-1] = 1; }
        else{ flag = 1; distinct2[n-i-1] = 0; }
      }
      else distinct2[n-i-1] = 0;
    }
    vector<pair<int,int> > ppp;
    for(int i=0;i<n-1;i++)
    {
      int x = i+1;
      int y = n-i-1;
      int xx = (x*(x+1))/2,yy = (y*(y+1))/2;
      if(prefix[i]==xx  && distinct1[i] && suffix[n-2-i]==yy && distinct2[n-i-2]){ ans++; ppp.push_back(make_pair(x,y)); }
    }
      std::cout <<ans<< '\n';
      for(int i=0;i<ppp.size();i++) std::cout <<ppp[i].first<<" "<<ppp[i].second<< '\n';
  }
  return 0;
}
 
 
?
Time: ? ms, memory: ? KB
Verdict: ?
Input
?
Participant's output
?
Jury's answer
?
Checker comment
?
Diagnostics
?
Click to see test details