QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#371017#4909. 《关于因为与去年互测zjk撞题而不得不改题这回事》2745518585Compile Error//C++205.9kb2024-03-29 21:05:272024-03-29 21:05:28

Judging History

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

  • [2024-03-29 21:05:28]
  • 评测
  • [2024-03-29 21:05:27]
  • 提交

answer

#pragma GCC optimize("Ofast")
#pragma GCC target("avx,sse2,sse3,sse4,mmx")
#pragma GCC optimize("Ofast")
#pragma GCC optimize("inline")
#pragma GCC optimize("-fgcse")
#pragma GCC optimize("-fgcse-lm")
#pragma GCC optimize("-fipa-sra")
#pragma GCC optimize("-ftree-pre")
#pragma GCC optimize("-ftree-vrp")
#pragma GCC optimize("-fpeephole2")
#pragma GCC optimize("-ffast-math")
#pragma GCC optimize("-fsched-spec")
#pragma GCC optimize("unroll-loops")
#pragma GCC optimize("-falign-jumps")
#pragma GCC optimize("-falign-loops")
#pragma GCC optimize("-falign-labels")
#pragma GCC optimize("-fdevirtualize")
#pragma GCC optimize("-fcaller-saves")
#pragma GCC optimize("-fcrossjumping")
#pragma GCC optimize("-fthread-jumps")
#pragma GCC optimize("-funroll-loops")
#pragma GCC optimize("-fwhole-program")
#pragma GCC optimize("-freorder-blocks")
#pragma GCC optimize("-fschedule-insns")
#pragma GCC optimize("inline-functions")
#pragma GCC optimize("-ftree-tail-merge")
#pragma GCC optimize("-fschedule-insns2")
#pragma GCC optimize("-fstrict-aliasing")
#pragma GCC optimize("-fstrict-overflow")
#pragma GCC optimize("-falign-functions")
#pragma GCC optimize("-fcse-skip-blocks")
#pragma GCC optimize("-fcse-follow-jumps")
#pragma GCC optimize("-fsched-interblock")
#pragma GCC optimize("-fpartial-inlining")
#pragma GCC optimize("no-stack-protector")
#pragma GCC optimize("-freorder-functions")
#pragma GCC optimize("-findirect-inlining")
#pragma GCC optimize("-fhoist-adjacent-loads")
#pragma GCC optimize("-frerun-cse-after-loop")
#pragma GCC optimize("inline-small-functions")
#pragma GCC optimize("-finline-small-functions")
#pragma GCC optimize("-ftree-switch-conversion")
#pragma GCC optimize("-foptimize-sibling-calls")
#pragma GCC optimize("-fexpensive-optimizations")
#pragma GCC optimize("-funsafe-loop-optimizations")
#pragma GCC optimize("inline-functions-called-once")
#pragma GCC optimize("-fdelete-null-pointer-checks")#include<cstdio>
#include<algorithm>
#include<vector>
#include<queue>
using namespace std;
typedef long long ll;
inline char gc()
{
    static char buf[100000],*p1=buf,*p2=buf;
    return p1==p2&&(p2=(p1=buf)+fread(buf,1,100000,stdin),p1==p2)?EOF:*p1++;
}
template<typename T> inline void read(T &x)
{
    T u=1,t=0;char c=gc();
    while(c<'0'||c>'9') {if(c=='-') u=-1; c=gc();}
    while(c>='0'&&c<='9') t*=10,t+=c-'0',c=gc();
    x=u*t;return;
}
template<typename T,typename ...O> inline void read(T &x,O &...o) {read(x),read(o...);}
template<typename T> inline void print(T x)
{
    if(x==0) return putchar('0'),void();
    if(x<0) putchar('-'),x=-x;
    int c[129]={0},k=0;
    while(x) c[++k]=x%10,x/=10;
    for(int i=k;i;--i) putchar(c[i]+'0');
}
template<typename T,typename ...O> inline void print(T x,O ...o) {print(x),putchar(' '),print(o...);}
const int N=1000001,M=31;
int n,m,tot,e[N];
ll b[N];
vector<int> a[N];
namespace ST
{
    int lg[N];
    ll a[N][M];
    int check(int x,int y)
    {
        return b[x]>b[y]?x:y;
    }
    void init()
    {
        for(int i=1;i<=n;++i) a[i][0]=e[i];
        for(int i=0;i<=20;++i)
        {
            for(int j=(1<<i);j<=min((1<<(i+1))-1,n);++j) lg[j]=i;
        }
        for(int i=1;i<=20;++i)
        {
            for(int j=1;j<=n;++j)
            {
                if(j+(1<<i)-1<=n) a[j][i]=check(a[j][i-1],a[j+(1<<(i-1))][i-1]);
            }
        }
    }
    int sum(int x,int y)
    {
        if(x>y) swap(x,y);
        return check(a[x][lg[y-x+1]],a[y-(1<<lg[y-x+1])+1][lg[y-x+1]]);
    }
}
struct tree
{
    int f,s,d,t,z,b;
}T[N];
struct str
{
    int x,y,t;
    str() {}
    str(int x,int y):x(x),y(y),t(ST::sum(T[x].b,T[y].b)) {}
    friend bool operator<(str x,str y)
    {
        return b[x.t]<b[y.t];
    }
};
priority_queue<str> Q1;
priority_queue<ll> Q2;
void dfs1(int x)
{
    T[x].s=1;
    T[x].d=T[T[x].f].d+1;
    for(auto i:a[x])
    {
        if(i==T[x].f) continue;
        T[i].f=x;
        dfs1(i);
        T[x].s+=T[i].s;
        if(T[i].s>T[T[x].z].s) T[x].z=i;
    }
}
void dfs2(int x,int t)
{
    T[x].b=++tot;
    T[x].t=t;
    if(T[x].z) dfs2(T[x].z,t);
    for(auto i:a[x])
    {
        if(i==T[x].f||i==T[x].z) continue;
        dfs2(i,i);
    }
}
void solve(int x,int y)
{
    while(T[x].t!=T[y].t)
    {
        if(T[T[x].t].d>T[T[y].t].d)
        {
            Q1.push(str(T[x].t,x));
            x=T[T[x].t].f;
        }
        else
        {
            Q1.push(str(T[y].t,y));
            y=T[T[y].t].f;
        }
    }
    Q1.push(str(x,y));
}
int main()
{
    read(n);
    for(int i=1;i<=n-1;++i)
    {
        int x,y;
        read(x,y);
        a[x].push_back(y);
        a[y].push_back(x);
    }
    for(int i=1;i<=n;++i) read(b[i]);
    dfs1(1);
    dfs2(1,1);
    for(int i=1;i<=n;++i) e[T[i].b]=i;
    ST::init();
    read(m);
    ll las=0;
    for(int i=1;i<=m;++i)
    {
        int x,y,k;
        read(x,y,k);
        x=(x^las)%n+1,y=(y^las)%n+1;
        while(!Q1.empty()) Q1.pop();
        while(!Q2.empty()) Q2.pop();
        solve(x,y);
        while(!Q1.empty()&&Q2.size()<k*62)
        {
            auto [x,y,t]=Q1.top();
            Q2.push(b[t]);
            Q1.pop();
            if(T[x].d>T[y].d) swap(x,y);
            if(T[x].d<T[t].d) Q1.push(str(x,T[t].f));
            if(T[t].d<T[y].d) Q1.push(str(T[t].z,y));
        }
        while(Q2.size()<k) Q2.push(0);
        ll s=0;
        for(int i=62;i>=0;--i)
        {
            static ll z[11];
            for(int j=1;j<=k;++j) z[j]=Q2.top(),Q2.pop();
            if((z[k]&(1ll<<i))!=0)
            {
                s|=(1ll<<i);
                for(int j=1;j<=k;++j) Q2.push(z[j]);
            }
            else
            {
                for(int j=1;j<=k;++j) Q2.push(z[j]&(~(1ll<<i)));
            }
        }
        print(las=s);
        putchar('\n');
    }
    return 0;
}

详细

answer.code:47:53: error: stray ‘#’ in program
   47 | #pragma GCC optimize("-fdelete-null-pointer-checks")#include<cstdio>
      |                                                     ^
answer.code:22:39: warning: bad option ‘-fwhole-program’ to pragma ‘optimize’ [-Wpragmas]
   22 | #pragma GCC optimize("-fwhole-program")
      |                                       ^
answer.code:29:41: warning: bad option ‘-fstrict-overflow’ to pragma ‘optimize’ [-Wpragmas]
   29 | #pragma GCC optimize("-fstrict-overflow")
      |                                         ^
answer.code:31:41: warning: bad option ‘-fcse-skip-blocks’ to pragma ‘optimize’ [-Wpragmas]
   31 | #pragma GCC optimize("-fcse-skip-blocks")
      |                                         ^
answer.code:45:51: warning: bad option ‘-funsafe-loop-optimizations’ to pragma ‘optimize’ [-Wpragmas]
   45 | #pragma GCC optimize("-funsafe-loop-optimizations")
      |                                                   ^
answer.code:47:54: error: ‘#pragma GCC optimize’ string is badly formed
   47 | #pragma GCC optimize("-fdelete-null-pointer-checks")#include<cstdio>
      |                                                      ^~~~~~~
answer.code:53:16: warning: bad option ‘-fwhole-program’ to attribute ‘optimize’ [-Wattributes]
   53 | inline char gc()
      |                ^
answer.code:53:16: warning: bad option ‘-fstrict-overflow’ to attribute ‘optimize’ [-Wattributes]
answer.code:53:16: warning: bad option ‘-fcse-skip-blocks’ to attribute ‘optimize’ [-Wattributes]
answer.code:53:16: warning: bad option ‘-funsafe-loop-optimizations’ to attribute ‘optimize’ [-Wattributes]
answer.code: In function ‘char gc()’:
answer.code:56:52: error: ‘stdin’ was not declared in this scope
   56 |     return p1==p2&&(p2=(p1=buf)+fread(buf,1,100000,stdin),p1==p2)?EOF:*p1++;
      |                                                    ^~~~~
answer.code:51:1: note: ‘stdin’ is defined in header ‘<cstdio>’; did you forget to ‘#include <cstdio>’?
   50 | #include<queue>
  +++ |+#include <cstdio>
   51 | using namespace std;
answer.code:56:33: error: ‘fread’ was not declared in this scope
   56 |     return p1==p2&&(p2=(p1=buf)+fread(buf,1,100000,stdin),p1==p2)?EOF:*p1++;
      |                                 ^~~~~
answer.code:56:67: error: ‘EOF’ was not declared in this scope
   56 |     return p1==p2&&(p2=(p1=buf)+fread(buf,1,100000,stdin),p1==p2)?EOF:*p1++;
      |                                                                   ^~~
answer.code:56:67: note: ‘EOF’ is defined in header ‘<cstdio>’; did you forget to ‘#include <cstdio>’?
answer.code: At global scope:
answer.code:58:43: warning: bad option ‘-fwhole-program’ to attribute ‘optimize’ [-Wattributes]
   58 | template<typename T> inline void read(T &x)
      |                                           ^
answer.code:58:43: warning: bad option ‘-fstrict-overflow’ to attribute ‘optimize’ [-Wattributes]
answer.code:58:43: warning: bad option ‘-fcse-skip-blocks’ to attribute ‘optimize’ [-Wattributes]
answer.code:58:43: warning: bad option ‘-funsafe-loop-optimizations’ to attribute ‘optimize’ [-Wattributes]
answer.code:65:65: warning: bad option ‘-fwhole-program’ to attribute ‘optimize’ [-Wattributes]
   65 | template<typename T,typename ...O> inline void read(T &x,O &...o) {read(x),read(o...);}
      |                                                                 ^
answer.code:65:65: warning: bad option ‘-fstrict-overflow’ to attribute ‘optimize’ [-Wattributes]
answer.code:65:65: warning: bad option ‘-fcse-skip-blocks’ to attribute ‘optimize’ [-Wattributes]
answer.code:65:65: warning: bad option ‘-funsafe-loop-optimizations’ to attribute ‘optimize’ [-Wattributes]
answer.code:66:43: warning: bad option ‘-fwhole-program’ to attribute ‘optimize’ [-Wattributes]
   66 | template<typename T> inline void print(T x)
      |                                           ^
answer.code:66:43: warning: bad option ‘-fstrict-overflow’ to attribute ‘optimize’ [-Wattributes]
answer.code:66:43: warning: bad option ‘-fcse-skip-blocks’ to attribute ‘optimize’ [-Wattributes]
answer.code:66:43: warning: bad option ‘-funsafe-loop-optimizations’ to attribute ‘optimize’ [-Wattributes]
answer.code: In function ‘void print(T)’:
answer.code:68:21: error: there are no arguments to ‘putchar’ that depend on a template parameter, so a declaration of ‘putchar’ must be available [-fpermissive]
   68 |     if(x==0) return putchar('0'),void();
      |                     ^~~~~~~
answer.code:68:21: note: (if you use ‘-fpermissive’, G++ will accept your code, but allowing the use of an undeclared name is deprecated)
answer.code:69:13: error: there are no arguments to ‘putchar’ that depend on a template parameter, so a declaration of ‘putchar’ must be available [-fpermissive]
   69 |     if(x<0) putchar('-'),x=-x;
      |             ^~~~~~~
answer.code:72:24: error: there are no arguments to ‘putchar’ that depend on a template parameter, so a declaration of ‘putchar’ ...