QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#471874#5033. Y 君的序列wsc2008Compile Error//C++141013b2024-07-11 10:42:212024-07-11 10:42:21

Judging History

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

  • [2024-07-11 10:42:21]
  • 评测
  • [2024-07-11 10:42:21]
  • 提交

answer

#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=(a);i<=(b);++i)
#define per(i,a,b) for(int i=(a);i>=(b);--i)
using namespace std;
const int N=1e5+9;
int a[N],b[N],pos[N],tar[N];
int clg(int x){
    int g=0;
    while((1<<g)<x)g++;
    return g;
}
void O(int x,int y,int c){
    int i=pos[x],j=pos[y];
    while(c--){
        if(x&1)add(j,i),x+=y/2,y/=2;
        else add(i,j),y+=x/2,x/=2;
    }
    swap(pos[x],pos[y]),swap(a[i],a[j]);
}
void remake(int x){
    int y=a[tar[x]];
    while(y!=1){
        int c=clg(y),z=(1<<c)+1-y;
        O(y,z,c);
        if(z==x)return;
        y=z;
    }
    vector<int>v;
    while(x!=1){
        v.push_back(x);
        int c=clg(x);
        x=(1<<c)+1-x;
    }
    reverse(v.begin(),v.end());
    for(int o:v){
        int c=clg(o),p=(1<<c)+1-o;
        O(p,o,c);
    }
}
void SEQ(int n,int M){
    answer(1);
    rep(i,1,n)a[i]=pos[i]=i,b[i]=Get(i),tar[b[i]]=i;
    per(i,n,1){
        if(pos[i]!=tar[i])remake(i);
    }
}

Details

implementer.cpp: In function ‘void {anonymous}::StAr_WaRs::main()’:
implementer.cpp:46:22: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   46 |                 scanf("%d %d",&n,&M);
      |                 ~~~~~^~~~~~~~~~~~~~~
implementer.cpp:47:45: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   47 |                 for (int i=1;i<=n;i++) scanf("%d",&b[i]),a[i]=i;
      |                                        ~~~~~^~~~~~~~~~~~
answer.code: In function ‘void O(int, int, int)’:
answer.code:15:16: error: ‘add’ was not declared in this scope; did you mean ‘fadd’?
   15 |         if(x&1)add(j,i),x+=y/2,y/=2;
      |                ^~~
      |                fadd
answer.code:16:14: error: ‘add’ was not declared in this scope; did you mean ‘fadd’?
   16 |         else add(i,j),y+=x/2,x/=2;
      |              ^~~
      |              fadd
answer.code: In function ‘void SEQ(int, int)’:
answer.code:41:5: error: ‘answer’ was not declared in this scope
   41 |     answer(1);
      |     ^~~~~~
answer.code:42:34: error: ‘Get’ was not declared in this scope
   42 |     rep(i,1,n)a[i]=pos[i]=i,b[i]=Get(i),tar[b[i]]=i;
      |                                  ^~~