QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#381923#5459. Goose, goose, DUCK?wsc2008Compile Error//C++142.6kb2024-04-07 22:01:062024-04-07 22:01:08

Judging History

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

  • [2024-04-07 22:01:08]
  • 评测
  • [2024-04-07 22:01:06]
  • 提交

answer

#include<bits/stdc++.h>
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
#define pii pair<ll,ll>
#define rep(i,a,b) for(ll i=(a);i<=(b);++i)
#define per(i,a,b) for(ll i=(a);i>=(b);--i)
using namespace std;
bool Mbe;
ll read(){
    ll x=0,f=1;char ch=getchar();
    while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
    while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
    return x*f;
}
void write(ll x){
    if(x<0)putchar('-'),x=-x;
    if(x>9)write(x/10);
    putchar(x%10+'0');
}
const ll N=1e6+9,V=1e6;
ll n,k,a[N],mn[N<<2],tr[N<<2],tag[N<<@];
vector<ll>vec[N];
struct O{
    ll l,r,sgn;
};
vector<O>vq[N];
void Build(ll x,ll l,ll r){
    mn[x]=0,tr[x]=r-l+1;
    if(l==r)return ;
    ll mid=(l+r)>>1;
    Build(x<<1,l,mid);
    Build(x<<1|1,mid+1,r);
}
void Pushup(ll x){
    mn[x]=min(mn[x<<1],mn[x<<1|1]);
    tr[x]=0;
    if(mn[x]==mn[x<<1])tr[x]+=tr[x<<1];
    if(mn[x]==mn[x<<1|1])tr[x]+=tr[x<<1|1];
}
void Pushtag(ll x,ll k){
    tag[x]+=k,mn[x]+=k;
}
void Pushdown(ll x){
    if(!tag[x])return ;
    Pushtag(x<<1,tag[x]);
    Pushtag(x<<1|1,tag[x]);
    tag[x]=0;
}
void Upd(ll x,ll l,ll r,ll ql,ll qr,ll v){
    if(l>qr||r<ql)return ;
    if(ql<=l&&r<=qr)return Pushtag(x,v),void();
    ll mid=(l+r)>>1;
    Pushdown(x);
    Upd(x<<1,l,mid,ql,qr,v);
    Upd(x<<1|1,mid+1,r,ql,qr,v);
    Pushup(x);
}
pii Query(ll x,ll l,ll r,ll ql,ll qr){
    if(l>qr||r<ql)return make_pair((ll)1e9,0);
    if(ql<=l&&r<=qr)return make_pair(mn[x],tr[x]);
    Pushdown(x);
    ll mid=(l+r)>>1;
    if(qr<=mid)return Query(x<<1,l,mid,ql,qr);
    if(ql>mid)return Query(x<<1|1,mid+1,r,ql,qr);
    pii L=Query(x<<1,l,mid,ql,qr),R=Query(x<<1|1,mid+1,r,ql,qr);
    pii res=make_pair(min(L.first,R.first),0);
    if(res.first==L.first)res.second+=L.second;
    if(res.first==R.first)res.second+=R.second;
    return res;
}
bool Med;
int main(){
    cerr<<fabs(&Med-&Mbe)/1048576.0<<"MB\n";
    n=read(),k=read();
    rep(i,1,n)a[i]=read(),vec[a[i]].push_back(i);
    rep(i,1,V){
        if((ll)vec[i].size()<k)continue;
        rep(j,0,(ll)vec[i].size()-k){
            ll Lx=(j==0?1:vec[i][j-1]+1);
            ll Ly=vec[i][j];
            ll Rx=vec[i][j+k-1];
            ll Ry=(j+k==(ll)vec[i].size()?n:vec[i][j+k]-1);
            vq[Lx].push_back((O){Rx,Ry,1});
            vq[Ly+1].push_back((O){Rx,Ry,-1});
        }
    }
    Build(1,1,n);
    ll ans=0;
    rep(i,1,n){
        for(O o:vq[i])Upd(1,1,n,o.l,o.r,o.sgn);
        pii qq=Query(1,1,n,i,n);
        if(qq.first==0)ans+=qq.second;
    }
    write(ans);
    return 0;
}

详细

answer.code:22:38: error: stray ‘@’ in program
   22 | ll n,k,a[N],mn[N<<2],tr[N<<2],tag[N<<@];
      |                                      ^
answer.code:22:39: error: expected primary-expression before ‘]’ token
   22 | ll n,k,a[N],mn[N<<2],tr[N<<2],tag[N<<@];
      |                                       ^
answer.code: In function ‘void Pushtag(ll, ll)’:
answer.code:42:5: error: ‘tag’ was not declared in this scope; did you mean ‘tan’?
   42 |     tag[x]+=k,mn[x]+=k;
      |     ^~~
      |     tan
answer.code: In function ‘void Pushdown(ll)’:
answer.code:45:9: error: ‘tag’ was not declared in this scope; did you mean ‘tan’?
   45 |     if(!tag[x])return ;
      |         ^~~
      |         tan
answer.code:46:18: error: ‘tag’ was not declared in this scope; did you mean ‘tan’?
   46 |     Pushtag(x<<1,tag[x]);
      |                  ^~~
      |                  tan