QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#290078#4617. Arithmetic SubsequenceyspmCompile Error//C++201.3kb2023-12-24 12:34:422023-12-24 12:34:43

Judging History

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

  • [2023-12-24 12:34:43]
  • 评测
  • [2023-12-24 12:34:42]
  • 提交

answer

#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<=b;++i)
using namespace std;
template<typename T>inline void ckmax(T &x,T y){x=x<y?y:x;}
template<typename T>inline void ckmin(T &x,T y){x=x>y?y:x;}
template<typename T=int>inline T read(){
    T res=0,f=1; char k;
    while(!isdigit(k=getchar())) if(k=='-') f=-1;
    while(isdigit(k)) res=res*10+k-'0',k=getchar();
    return res*f;
}
template<typename T>inline void print(T x,bool fl=1){
    if(x<0) putchar('-'),x=-x; 
    if(x>=10) print(x/10,0);
    putchar(x%10+'0');
    if(fl) putchar('\n');
}
const int N=5010;
int a[N],b[N],n,ta[N],tb[N];
bool Fail=0;
inline void solve(int l,int r){
    if(a[l]==a[r]){
        if(r-l+1>=3) Fail=1;
        return ;
    }
    int c1=l-1,c2=r+1;
    rep(i,l,r) if(a[i]&1) ta[++c1]=a[i]/2,tb[c1]=b[i];
    rep(i,l,r) if(a[i]%2==0) ta[--c1]=a[i]/2,tb[c1]=b[i];
    rep(i,l,r) a[i]=ta[i],b[i]=tb[i];
    solve(l,cl); solve(cr,r);
    return ;
}
int main(){
    int T=read();
    while(T--){
        n=read();
        for(int i=1;i<=n;++i) b[i]=a[i]=read();
        solve(1,n);
        if(Fail){
            Fail=0;
            puts("NO");
            continue;
        }
        puts("YES");
        for(int i=1;i<n;++i) printf("%d ",b[i]);
        printf("%d\n",b[n]);
    }
    return 0;
}

详细

answer.code: In function ‘void solve(int, int)’:
answer.code:30:13: error: ‘cl’ was not declared in this scope; did you mean ‘c2’?
   30 |     solve(l,cl); solve(cr,r);
      |             ^~
      |             c2
answer.code:30:24: error: ‘cr’ was not declared in this scope; did you mean ‘c2’?
   30 |     solve(l,cl); solve(cr,r);
      |                        ^~
      |                        c2