QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#635684#8719. 后继ainuoCompile Error//C++141.1kb2024-10-12 20:35:382024-10-12 20:35:38

Judging History

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

  • [2024-10-12 20:35:38]
  • 评测
  • [2024-10-12 20:35:38]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
const int N=4e5+10;
int p[N];
int num[N][32];
int ans[32];
int n,m,len=0;

int query(int u)
{
    int f;
    cout<<"? "<<u<<'\n';
    cin>>f;
    return f;
}

void solve()
{
    int dx=0;
    for(int i=len;i>=1;i++)
    {
        int flg_0=0,flg_1=0;
        for(int j=1;j<=n;j++)
        {
            if(num[j][i]==1) flg_1=1;
            if(num[j][i]==0) flg_0=1;
        }
        if(flg_0==0||flg_1==0) 
        {
            ans[i]=0;
            continue;
        }
        int d=1+dx;
        int t=query(d);
        if(t==-1)
        {
            dx++;
            d=1+dx;
            t=query(d);
        }
        if(num[t][i]==num[d][i]) ans[i]=num[t][i];
        else ans=1-num[t][i];
    }
}

int main()
{
    cin>>n>>m;
    for(int i=1;i<=n;i++) cin>>p[i];
    for(int i=1;i<=n;i++)
    {
        int x=p[i],cnt=0;
        while(x)
        {
            num[i][++cnt]=x%2;
            x/=2;
        }
        len=max(len,cnt);
    }
    while(m--) solve();
    return 0;
}

详细

answer.code: In function ‘void solve()’:
answer.code:42:17: error: incompatible types in assignment of ‘int’ to ‘int [32]’
   42 |         else ans=1-num[t][i];
      |              ~~~^~~~~~~~~~~~