Aborted / IOT trap是怎么回事啊
查看原帖
Aborted / IOT trap是怎么回事啊
295864
eigw22h619楼主2022/3/20 01:00

Received signal 6: Aborted / IOT trap.

#include<stdio.h>
#define cn const
#include<algorithm>
inline int re()
{
    int x=0;bool f=0;register char ch=getchar();
    while(ch<'0'||ch>'9'){f=(ch=='-');ch=getchar();}
    while(ch>='0'&&ch<='9'){x=(x<<3)+(x<<1)+(ch&15);ch=getchar();}
    return f?-x:x;
}
inline void wr(cn int&x)
{
    if(x>=10)wr(x/10);
    putchar(x%10^'0');
}
inline void wr(cn int&x,cn char&c)
{x>=0?wr(x):(putchar('-'),wr(-x));putchar(c);}
int*s;
inline bool ccc(cn int&a,cn int&b){return s[a]<s[b];}
void gtrk(int*st,int*ed,int*oS)
{
    cn int n=ed-st;int *aa=new int [n],*p=new int [n];
    s=--st;
    for(int i=n;i;--i){p[i]=i;aa[i]=st[i];}
    std::sort(p+1,p+1+n,ccc);
    for(int i=n;i;--i)oS[p[i]]=i;
    for(int i=2;i<=n;++i)if(aa[p[i-1]]==aa[p[i]])
    oS[p[i]]=oS[p[i-1]];
}
constexpr int N=200001;
struct xx{int ls,rs,a,l,r;xx(){}};
int n;xx t[4138000];
#define l(p) t[p].l
#define r(p) t[p].r
#define ls(p) t[p].ls
#define rs(p) t[p].rs
#define a(p) t[p].a
int rt[N],rts,nds;
void ins(cn int&x)
{
    int o=rt[rts],c=rt[++rts]=++nds;
    while(l(o)!=r(o))
    {
        t[c]=t[o];a(c)=a(o)+1;
        if(x>l(o)+r(o)>>1)
        {
            rs(c)=++nds;
            o=rs(o);
        }
        else
        {
            ls(c)=++nds;
            o=ls(o);
        }
        c=nds;
    }
    t[c]=t[o];a(c)=a(o)+1;
}
int ans(int k,cn int&r,cn int&l)
{
    int o=rt[l-1],c=rt[r];
    while(l(o)!=r(o))
    if(k>a(ls(c))-a(ls(o))){k-=a(ls(c))-a(ls(o));c=rs(c);o=rs(o);}
    else{c=ls(c);o=ls(o);}
    return l(o);
}
void dfs(cn int p)
{
    if(l(p)==r(p))return ;
    cn int m=l(p)+r(p)>>1;
    ls(p)=++nds;l(nds)=l(p);r(nds)=m;dfs(nds);
    rs(p)=++nds;l(nds)=m+1;r(nds)=r(p);dfs(nds);
}
void build(cn int&sz)
{
    nds=1;n=sz;rt[0]=1;l(1)=1;r(1)=n;dfs(1);
}
int a[N],b[N],c[N];
int main()
{
    cn int n=re();int m=re();build(n);
    for(int i=1;i<=n;++i)a[i]=re();
    gtrk(a+1,a+1+n,b);
    for(int i=1;i<=n;++i)ins(b[i]);
    for(int i=1;i<=n;++i)c[b[i]]=a[i];
    while(m --> 0)wr(c[ans(re(),re(),re())],10);
    return 0;
}

input file

10 10
7157 27211 7778 11271 12240 24315 8149 14437 19151 30450 
1 8 5
1 8 5
1 8 8
1 8 7
1 8 1
1 8 4
1 8 4
1 8 8
1 8 8
1 8 3

2022/3/20 01:00
加载中...