QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#635705#8719. 后继ainuoWA 1ms5680kbC++141.2kb2024-10-12 20:40:412024-10-12 20:40:41

Judging History

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

  • [2024-10-12 20:40:41]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:5680kb
  • [2024-10-12 20:40:41]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
const int N=4e5+10;
typedef long long ll;
ll 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[i]=1-num[t][i];
    }
    ll ans_num=0;
    for(int i=1;i<=len;i++)
    {
        ans_num=ans_num*2+ans[i];
    }
    cout<<"! "<<ans<<'\n';

}

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;
}

詳細信息

Test #1:

score: 0
Wrong Answer
time: 1ms
memory: 5680kb

input:

5 1
1 2 3 4 5
5
5
5

output:

? 1
? 1
? 1
! 0x5613c64a52a0

result:

wrong answer Answer contains longer sequence [length = 1], but output contains 0 elements