QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#411167#6528. SequenceRafi22Compile Error//C++143.3kb2024-05-15 06:01:002024-05-15 06:01:02

Judging History

你现在查看的是最新测评结果

  • [2024-05-15 06:01:02]
  • 评测
  • [2024-05-15 06:01:00]
  • 提交

answer

#include <bits/stdc++.h>

#define int long long
#define ll long long
#define ld long double
#define endl '\n'
#define st first
#define nd second
#define pb push_back
#define sz(x) (int)(x).size()
#define all(x) (x).begin(), (x).end()
using namespace std;
int inf=1000000007;
ll infl=1000000000000000007;
int mod=998244353;

const int N=500007,pot=1<<19;

struct T1
{
    int seg[2*pot+7],lzy[2*pot+7];
    T1()
    {
        memset(seg,0,sizeof seg);
        memset(lzy,0,sizeof lzy);
    }
    void push(int v)
    {
        seg[2*v]+=lzy[v];
        lzy[2*v]+=lzy[v];
        seg[2*v+1]+=lzy[v];
        lzy[2*v+1]+=lzy[v];
        lzy[v]=0;
    }
    void ins(int v,int a,int b,int l,int r,int x)
    {
        if(a<=l&&b>=r)
        {
            seg[v]+=x;
            lzy[v]+=x;
            return ;
        }
        if(r<a||l>b) return ;
        push(v);
        ins(2*v,a,b,l,(l+r)/2,x);
        ins(2*v+1,a,b,(l+r)/2+1,r,x);
        seg[v]=min(seg[2*v],seg[2*v+1]);
    }
    int que(int v,int a,int b,int l,int r)
    {
        if(a<=l&&b>=r) return seg[v];
        if(r<a||l>b) return inf;
        push(v);
        return min(que(2*v,a,b,l,(l+r)/2),que(2*v+1,a,b,(l+r)/2+1,r));
    }
};

struct T2
{
    int seg[2*pot+7],lzy[2*pot+7];
    T2()
    {
        memset(seg,0,sizeof seg);
        memset(lzy,0,sizeof lzy);
    }
    void push(int v)
    {
        seg[2*v]+=lzy[v];
        lzy[2*v]+=lzy[v];
        seg[2*v+1]+=lzy[v];
        lzy[2*v+1]+=lzy[v];
        lzy[v]=0;
    }
    void ins(int v,int a,int b,int l,int r,int x)
    {
        if(a<=l&&b>=r)
        {
            seg[v]+=x;
            lzy[v]+=x;
            return ;
        }
        if(r<a||l>b) return ;
        push(v);
        ins(2*v,a,b,l,(l+r)/2,x);
        ins(2*v+1,a,b,(l+r)/2+1,r,x);
        seg[v]=max(seg[2*v],seg[2*v+1]);
    }
    int que(int v,int a,int b,int l,int r)
    {
        if(a<=l&&b>=r) return seg[v];
        if(r<a||l>b) return -inf;
        push(v);
        return max(que(2*v,a,b,l,(l+r)/2),que(2*v+1,a,b,(l+r)/2+1,r));
    }
};


vector<int>V[N];

int sequence(int n,vector<int>a)
{
    for(int i=0;i<n;i++) V[a[i]].pb(i+1);
    T1 Lmn,Rmn;
    T2 Lmx,Rmx;
    for(int i=0;i<=n;i++)
    {
        Lmn.ins(1,i+1,n+1,1,pot,-1);
        Rmn.ins(1,i+1,n+1,1,pot,-1);
        Lmx.ins(1,i+1,n+1,1,pot,-1);
        Rmx.ins(1,i+1,n+1,1,pot,-1);
    }
    int ans=0;
    for(int k=1;k<=n;k++)
    {
        for(auto i:V[k])
        {
            Rmx.ins(1,i+1,n+1,1,pot,2);
            Rmn.ins(1,i+1,n+1,1,pot,2);
        }
        int j=0;
        for(int i=0;i<sz(V[k]);i++)
        {
            while(j+1<sz(V[k]))
            {
                int L=Lmn.que(1,V[k][j+1]+1,n+1,1,pot)-Rmx.que(1,1,V[k][i],1,pot);
                int R=Rmx.que(1,V[k][j+1]+1,n+1,1,pot)-Rmn.que(1,1,V[k][i],1,pot);
                if(L<=0&&R>=0) j++;
                else break;
            }
            ans=max(ans,j-i+1);
        }
        for(auto i:V[k])
        {
            Lmx.ins(1,i+1,n+1,1,pot,2);
            Lmn.ins(1,i+1,n+1,1,pot,2);
        }
    }
    return ans;
}
/*
signed main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    cout<<sequence(7, {1, 2, 3, 1, 2, 1, 3});

    return 0;
}*/

Details

/usr/bin/ld: /tmp/ccKsTW2P.o: in function `main':
implementer.cpp:(.text.startup+0x2ab): undefined reference to `sequence(int, std::vector<int, std::allocator<int> >)'
collect2: error: ld returned 1 exit status