Codeforces Round #604 (Div. 2) Beautiful Regional Contest

简单模拟

#include 
#include
#include
#include
using namespace std;

const int maxn=400010;
int a[maxn];

void solve()
{
    int n;
    cin>>n;
    for(int i=1;i<=n;i++) cin>>a[i];
    int g=0,s=0,d=0,x=0;
    for(int i=2;i<=n/2;i++)
    {
        if(a[i]!=a[i-1]) {x=i-1;break;}
    }
    g=x;
    int k=a[g+1],bk=0;
    for(int i=x+2;i<=n/2;i++)
    {
        if(a[i]!=k&&i-g-1>g) {s=i-g-1;x=i;break;}
        else if(a[i]!=k&&i-g-1<=g) {k=a[i];}
    }
    for(int i=n/2+1;i>=x;i--)
    {
        if(a[i]!=a[i-1]){d=i-x;break;}
    }
    if(g>=s||g>=d||g+s+d>n/2) cout<<"0 0 0"<>t;
    while(t--)
    {
        solve();
    }
    return 0;
}

  

你可能感兴趣的:(Codeforces Round #604 (Div. 2) Beautiful Regional Contest)