QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#774207#9783. Duloc Networkucup-team3555#WA 1ms3588kbC++201.5kb2024-11-23 12:26:152024-11-23 12:26:17

Judging History

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

  • [2024-11-23 12:26:17]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:3588kb
  • [2024-11-23 12:26:15]
  • 提交

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'