QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#774207 | #9783. Duloc Network | ucup-team3555# | WA | 1ms | 3588kb | C++20 | 1.5kb | 2024-11-23 12:26:15 | 2024-11-23 12:26:17 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=203;
int n,f[N],ans[N];
void NB(int x){cout<<"! "<<x<<endl;exit(0);}
int F(int x){return f[x]==x?x:f[x]=F(f[x]);}
bool Chk()
{
for(int i=1;i<=n;i++)if(F(i)==F(1))return 0;
return 1;
}
int Ask(vector<int>v)
{
vector<int>vis(n+1,0);
for(int x:v)vis[x]=1;
for(int i=1;i<=n;i++)cout<<vis[i];
cout<<endl;
int s;cin>>s;return s;
}
void Mer(int x,int y)
{
x=F(x);y=F(y);
if(x==y)return;
vector<int>ask;ans[y]=0;f[F(y)]=F(x);
for(int i=1;i<=n;i++)if(F(i)==F(x))ask.push_back(i);
ans[x]=Ask(ask);
}
int main()
{
cin>>n;
for(int i=1;i<=n;i++)f[i]=i,ans[i]=Ask({i});
while(1)
{
vector<int>ve;int sz=0,all=0;
for(int i=1;i<=n;i++)if(F(i)==i)ve.push_back(i),sz++,all+=ans[i];
if(sz==1)NB(1);
int s=Ask(ve);
if(s==all)NB(0);
vector<array<int,2>>nb;
for(int i=0;i<sz;i++)
{
vector<int>v;
for(int j=0;j<sz;j++)if(j!=i)v.push_back(ve[j]);
while(v.size()>1)
{
int mid=v.size()/2,sum=0;vector<int>ask;
for(int j=0;j<mid;j++)ask.push_back(v[j]),sum+=ans[v[j]];
sum+=ans[ve[i]];ask.push_back(ve[i]);s=Ask(ask);
ask.pop_back();
if(sum>s){v=ask;continue;}
ask.clear();sum=0;
for(int j=mid;j<(int)v.size();j++)ask.push_back(v[j]),sum+=ans[v[j]];
sum+=ans[ve[i]];ask.push_back(ve[i]);s=Ask(ask);ask.pop_back();
if(sum>s){v=ask;continue;}
NB(0);
}
nb.push_back({ve[i],v[0]});
}
for(auto t:nb)Mer(t[0],t[1]);
}
}
詳細信息
Test #1:
score: 0
Wrong Answer
time: 1ms
memory: 3588kb
input:
4
output:
1000
result:
wrong answer format Expected '!' or '?', but found '1000'