QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#333351#4909. 《关于因为与去年互测zjk撞题而不得不改题这回事》11d10xyCompile Error//C++142.3kb2024-02-19 20:42:042024-02-19 20:42:05

Judging History

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

  • [2024-02-19 20:42:05]
  • 评测
  • [2024-02-19 20:42:04]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
using i64=long long;
constexpr int mxn=1000000;
int n,q,N,tot,mx[25][mxn+10],fa[mxn+10],dep[mxn+10],dfn[mxn+10],top[mxn+10],sz[mxn+10],tp;
basic_string<int>G[1000010];
i64 val[mxn+10],a[mxn+10];
auto midx=[](int x,int y){return val[x]>val[y]?x:y;};
auto qry=[](int l,int r){
   int g=__lg(r-l+1);
   return midx(mx[g][l],mx[g][r-(1<<g)+1]);
};
struct seg_t{
   int l,r,v;
   seg_t(int x,int y):l(x),r(y),v(qry(l,r)){};
   bool operator<(const seg_t&o)const{return val[v]<val[o.v];}
};
void dfs1(int u){
   dep[u]=dep[fa[u]]+1,sz[u]=1;
   if(fa[u])G[u].erase(find(begin(G[u]),end(G[u]),fa[u]));
   for(int&v:G[u])if(v!=fa[u]){
      fa[v]=u,dfs1(v),sz[u]+=sz[v];
      if(sz[v]>sz[G[u][0]])swap(v,G[u][0]);
   }
}
void dfs2(int u,int t){
   dfn[u]=++tot,val[tot]=a[u],mx[0][tot]=tot,top[u]=t;
   for(int v:G[u])dfs2(v,v==G[u][0]?t:v);
}
auto ri=[](auto&x){x=0;
   char c=getchar_unlocked();
   while(!isdigit(c))c=getchar_unlocked();
   while(isidigit(c))x=x*10+c-'0',c=getchar_unlocked();
};
int main(){
   ri(n);
   for(int i=1,u,v;i<n;i++)ri(u),ri(v),G[u]+=v,G[v]+=u;
   for(int i=1;i<=n;i++)ri(a[i]);
   dfs1(1),dfs2(1,1);
   for(int i=1;n>>i;i++)for(int k=1;k+(1<<i)-1<=n;k++)
   mx[i][k]=midx(mx[i-1][k],mx[i-1][k+(1<<i-1)]);
   i64 lstans=0;cin>>q;
   for(int u,v,k;q--;){
      static priority_queue<seg_t>q;
      ri(u),ri(v),ri(k);
      u=(u^lstans)%n+1,v=(v^lstans)%n+1,lstans=0;
      for(;!q.empty();q.pop());
      auto nex=[]{
         if(q.empty())return 0ll;
         auto[l,r,p]=q.top();q.pop();
         if(l<p)q.emplace(l,p-1);
         if(p<r)q.emplace(p+1,r);
         return val[p];
      };
      for(;top[u]!=top[v];u=fa[top[u]]){
         if(dep[top[u]]<dep[top[v]])swap(u,v);
         q.emplace(dfn[top[u]],dfn[u]);
      }if(dfn[u]>dfn[v])swap(u,v);
      q.emplace(dfn[u],dfn[v]);
      vector<i64>b;
      generate_n(back_inserter(b),k*62,nex);
      for(i64 w=1ll<<61;w;w>>=1){
         int c=0;
         auto it=upper_bound(begin(b),end(b),w,greater<>{});
         for_each(begin(b),it,[=](i64&x){x^=w;});
         if(it-begin(b)>=k)b.erase(it,end(b)),lstans|=w;
         else{
            inplace_merge(begin(b),it,end(b),greater<>{});
         }
      }printf("%lld\n",lstans);
   }
   return 0;
}

詳細信息

answer.code: In lambda function:
answer.code:33:10: error: there are no arguments to ‘isidigit’ that depend on a template parameter, so a declaration of ‘isidigit’ must be available [-fpermissive]
   33 |    while(isidigit(c))x=x*10+c-'0',c=getchar_unlocked();
      |          ^~~~~~~~
answer.code:33:10: note: (if you use ‘-fpermissive’, G++ will accept your code, but allowing the use of an undeclared name is deprecated)
answer.code: In instantiation of ‘<lambda(auto:1&)> [with auto:1 = int]’:
answer.code:36:6:   required from here
answer.code:33:18: error: ‘isidigit’ was not declared in this scope; did you mean ‘isxdigit’?
   33 |    while(isidigit(c))x=x*10+c-'0',c=getchar_unlocked();
      |          ~~~~~~~~^~~
      |          isxdigit
answer.code: In instantiation of ‘<lambda(auto:1&)> [with auto:1 = long long int]’:
answer.code:38:27:   required from here
answer.code:33:18: error: ‘isidigit’ was not declared in this scope; did you mean ‘isxdigit’?
   33 |    while(isidigit(c))x=x*10+c-'0',c=getchar_unlocked();
      |          ~~~~~~~~^~~
      |          isxdigit
answer.code: In lambda function:
answer.code:50:14: warning: structured bindings only available with ‘-std=c++17’ or ‘-std=gnu++17’ [-Wc++17-extensions]
   50 |          auto[l,r,p]=q.top();q.pop();
      |              ^