QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#443320#8079. Range Periodicity Queryrotcar07Compile Error//C++142.0kb2024-06-15 15:09:302024-06-15 15:09:30

Judging History

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

  • [2024-06-15 15:38:16]
  • hack成功,自动添加数据
  • (/hack/699)
  • [2024-06-15 15:32:38]
  • hack成功,自动添加数据
  • (/hack/698)
  • [2024-06-15 15:28:06]
  • hack成功,自动添加数据
  • (/hack/696)
  • [2024-06-15 15:23:18]
  • hack成功,自动添加数据
  • (/hack/695)
  • [2024-06-15 15:09:30]
  • 评测
  • [2024-06-15 15:09:30]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
constexpr int N=5e5+5;
int n,m,q,L[N],R[N],ans[N],t[N<<2];
vector<int> Q[N],P[N],E[N];
constexpr int inf=1e9;
#define ls p<<1
#define rs p<<1|1
inline void U(int p){t[p]=min(t[ls],t[rs]);}
void B(int p,int l,int r){
    t[p]=inf;
    if(l==r) return;
    int mid=l+r>>1;
    B(ls,l,mid),B(rs,mid+1,r);
}
void M(int p,int l,int r,int k,int x){
    if(l==r) return t[p]=x,void();
    int mid=l+r>>1;
    if(k<=mid) M(ls,l,mid,k,x);
    else M(rs,mid+1,r,k,x);
    U(p);
}
int Y(int p,int l,int r,int ql,int qr){
    if(ql<=l&&r<=qr) return t[p];
    int mid=l+r>>1,res=inf;
    if(ql<=mid) res=Y(ls,l,mid,ql,qr);
    if(qr>mid) res=min(res,Y(rs,mid+1,r,ql,qr));
    return res;
}
typedef unsigned long long Z;
constexpr Z mod=998244853;
const Z bas=random_device{}()%1000000+2000;
Z bs[N],hsh[N];
inline Z G(int l,int r){
    return (hsh[r]+mod-hsh[l-1]*bs[r-l+1]%mod)%mod;
}
string s,r,rv;int dt[maxn];
int main(){
    std::ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    cin>>n>>s>>m;for(int i=bs[0]=1;i<=n;i++) bs[i]=bs[i-1]*bas%mod;
    for(int i=1,x;i<=m;i++) cin>>x,P[x].push_back(i);cin>>q;
    for(int i=1,x;i<=q;i++) cin>>x>>L[i]>>R[i],Q[x].push_back(i);
    for(int i=1;i<n;i++) if(s[i]>='a'&&s[i]<='z') dt[1]++;
    for(int i=1;i<n;i++) dt[i+1]=dt[i]-(s[i]>='a'&&s[i]<='z');
    for(auto x:s) if(x>='a'&&x<='z') rv+=x;else r+=x+'a'-'A';
    reverse(rv.begin(),rv.end());r=rv+r;
    for(int i=0;i<n;i++) hsh[i+1]=(hsh[i]*bas+r[i])%mod;
    for(int i=1;i<=n;i++){
        int l=i,r=n;
        while(l<r){
            int mid=l+r+1>>1,d=dt[mid],L=mid-i;
            if(G(d+1,d+L)==G(d+mid-L+1,d+mid)) l=mid;
            else r=mid-1;
        }E[l+1].push_back(i);
    }B(1,1,m);
    for(int i=1;i<=n;i++){
        for(auto x:P[i]) M(1,1,m,x,i);
        for(auto x:E[i])for(auto y:P[x]) M(1,1,m,y,inf);
        for(auto x:Q[i]) ans[x]=Y(1,1,m,L[x],R[x]);
    }
    for(int i=1;i<=q;i++) cout<<(ans[i]==inf?-1:ans[i])<<'\n';
}

詳細信息

answer.code:37:22: error: ‘maxn’ was not declared in this scope
   37 | string s,r,rv;int dt[maxn];
      |                      ^~~~
answer.code: In function ‘int main()’:
answer.code:43:51: error: ‘dt’ was not declared in this scope; did you mean ‘t’?
   43 |     for(int i=1;i<n;i++) if(s[i]>='a'&&s[i]<='z') dt[1]++;
      |                                                   ^~
      |                                                   t
answer.code:44:26: error: ‘dt’ was not declared in this scope; did you mean ‘t’?
   44 |     for(int i=1;i<n;i++) dt[i+1]=dt[i]-(s[i]>='a'&&s[i]<='z');
      |                          ^~
      |                          t
answer.code:51:32: error: ‘dt’ was not declared in this scope; did you mean ‘d’?
   51 |             int mid=l+r+1>>1,d=dt[mid],L=mid-i;
      |                                ^~
      |                                d
answer.code:52:23: error: invalid conversion from ‘int*’ to ‘int’ [-fpermissive]
   52 |             if(G(d+1,d+L)==G(d+mid-L+1,d+mid)) l=mid;
      |                      ~^~
      |                       |
      |                       int*
answer.code:34:22: note:   initializing argument 2 of ‘Z G(int, int)’
   34 | inline Z G(int l,int r){
      |                  ~~~~^
answer.code:52:35: error: invalid operands of types ‘int’ and ‘int [500005]’ to binary ‘operator-’
   52 |             if(G(d+1,d+L)==G(d+mid-L+1,d+mid)) l=mid;
      |                              ~~~~~^~
      |                               |    |
      |                               int  int [500005]