QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#810681#9783. Duloc NetworkBINYUWA 1ms3736kbC++141.1kb2024-12-12 09:05:162024-12-12 09:05:18

Judging History

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

  • [2024-12-12 09:05:18]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:3736kb
  • [2024-12-12 09:05:16]
  • 提交

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;
		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])
			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);
}
/*
*/

详细

Test #1:

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

input:

4
1
3
2
2
2
1
2
2
2
2

output:

? 1000
? 0100
? 0010
? 0001
? 1010
? 0011
? 1001
? 0110
? 0101
? 1100
! 0

result:

wrong answer Wrong answer.