QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#810683#9783. Duloc NetworkBINYUWA 1ms3776kbC++141.1kb2024-12-12 09:06:372024-12-12 09:06:37

Judging History

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

  • [2024-12-12 09:06:37]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:3776kb
  • [2024-12-12 09:06:37]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
const int N = 200;
int n,d[N + 5];
vector <pair <int,int> > a;
struct DSU
{
	int f[N + 5];
	void init(int n)
	{
		for(int i = 1;i <= n;i++)f[i] = i;	
	}
	int fnd(int x)
	{
		return f[x] == x ? x : f[x] = fnd(f[x]);
	}
	bool merge(int x,int y)
	{
		x = fnd(x);y = fnd(y);
		if(x == y)return 0;
		f[x] = y;
		return 1;
	}
}dsu;
int query(int x,int y)
{
	putchar('?');putchar(' ');
	for(int i = 1;i <= n;i++)
		putchar((i == x||i == y) ? '1' : '0');
	puts("");fflush(stdout);
	int res;
	scanf("%d",&res);
	return res;
}
int main()
{
	srand(time(0));
	scanf("%d",&n);
	dsu.init(n);
	for(int i = 1;i <= n;i++)
		d[i] = query(i,0);
	int m = 3500 - n; 
	for(int i = 1;i <= n;i++)
		for(int j = i + 1;j <= n;j++)
			a.push_back({i,j});
	random_shuffle(a.begin(),a.end());
	for(int i = 0;i < m&&i < a.size();i++)
	{
		int u = a[i].first,v = a[i].second;
		if(query(u,v) != d[u] + d[v])
			cout<<u<<" - "<<v<<"\n",
			dsu.merge(u,v);
	}
	for(int i = 1;i <= n;i++)
		if(dsu.fnd(i) != dsu.fnd(1))
			return puts("! 0"),fflush(stdout),0;
	puts("! 1");fflush(stdout);
}
/*
*/

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

4
1
3
2
2
1

output:

? 1000
? 0100
? 0010
? 0001
? 0011
3 - 4
? 0101

result:

wrong answer format  Expected '!' or '?', but found '3'