报错:nothing is compiled,output exceeds
#include<iostream>
#define ll long long
using namespace std;
ll read()
{
bool flag=0;
char ch=getchar();
ll ans=0;
while(!isdigit(ch) && ~ch)
{
flag|=(ch=='-');
ch=getchar();
}
while(isdigit(ch) && ~ch)
{
ans=(ans<<1)+(ans<<3)+(ch^48);
ch=getchar();
}
return flag ? -ans : ans;
}
int _c[100];
void write(ll x)
{
int i=0;
if(x<0) {x=-x;putchar('-');}
if(x==0) putchar('0');
while(x) {_c[++i]=x%10;x/=10;}
while(i) {putchar(_c[i--]^48);}
}
struct node{
int lc=-1,rc=-1;
int lazytag=0;
ll sum=0;
bool use=1;
ll maxsuffix=0;
};
node tree[4500001];
int trsize=0;
int n,m;
void build(ll cur){
tree[cur].lc=trsize+1;
trsize++;
tree[cur].rc=trsize+1;
trsize++;
return;
}
void push_down(ll cur,ll nowl,ll nowr){
int lcl=nowl,lcr=(nowl+nowr)/2;
int rcl=(nowl+nowr)/2+1,rcr=nowr;
if(tree[cur].use==0) return;
tree[tree[cur].lc].lazytag=tree[cur].lazytag;
tree[tree[cur].lc].sum=(lcr-lcl+1)*tree[cur].lazytag;
tree[tree[cur].lc].maxsuffix=max((ll)(0),(ll)(tree[tree[cur].lc].sum));
tree[tree[cur].lc].use=1;
tree[tree[cur].rc].lazytag=tree[cur].lazytag;
tree[tree[cur].rc].sum=(rcr-rcl+1)*tree[cur].lazytag;
tree[tree[cur].rc].maxsuffix=max((ll)(0),tree[tree[cur].rc].sum);
tree[tree[cur].rc].use=1;
tree[cur].lazytag=0;
tree[cur].use=0;
}
void modify(ll l,ll r,ll cur,ll k,ll nowl,ll nowr){
if(nowl>=l&&nowr<=r){
tree[cur].lazytag=k;
tree[cur].sum=(nowr-nowl+1)*tree[cur].lazytag;
tree[cur].use=1;
tree[cur].maxsuffix=max((ll)(0),tree[cur].sum);
return;
}
if(nowl>r||nowr<l){
return;
}
if(tree[cur].lc==-1){build(cur);
}
push_down(cur,nowl,nowr);
modify(l,r,tree[cur].lc,k,nowl,(nowl+nowr)/2);
modify(l,r,tree[cur].rc,k,(nowl+nowr)/2+1,nowr);
tree[cur].sum=tree[tree[cur].lc].sum+tree[tree[cur].rc].sum;
tree[cur].maxsuffix=max(tree[tree[cur].lc].maxsuffix,tree[tree[cur].lc].sum+tree[tree[cur].rc].maxsuffix);
}
ll query(ll q,ll cur,ll nowl,ll nowr){
if(nowl==nowr){
if(q>=tree[cur].sum)return nowl;
else return nowl-1;
}
if(tree[cur].lc==-1){
build(cur);
}
push_down(cur,nowl,nowr);
if(q>=tree[tree[cur].lc].sum&&q>=tree[tree[cur].lc].maxsuffix){
return query(q-tree[tree[cur].lc].sum,tree[cur].rc,(nowl+nowr)/2+1,nowr);
}
else return query(q,tree[cur].lc,nowl,(nowl+nowr)/2);
}
int main(){
n=read();
while(1){
char op;
cin>>op;
if(op=='I'){
ll l,r,k;
l=read();
r=read();
k=read();
modify(l-1,r-1,0,k,0,n-1);
}
if(op=='Q'){
ll q;
q=read();
write(query(q,0,0,n-1)+1);
putchar('\n');
}
if(op=='E'){
return 0;
}
}
}