QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#774217#9783. Duloc Networkucup-team3555#WA 3ms3788kbC++201.5kb2024-11-23 12:29:222024-11-23 12:29:27

Judging History

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

  • [2024-11-23 12:29:27]
  • 评测
  • 测评结果:WA
  • 用时:3ms
  • 内存:3788kb
  • [2024-11-23 12:29:22]
  • 提交

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;
	cout<<"? ";
	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: 100
Accepted
time: 1ms
memory: 3596kb

input:

4
1
3
2
2
0
2
2
2
2
2
1
0

output:

? 1000
? 0100
? 0010
? 0001
? 1111
? 1100
? 1100
? 1010
? 1001
? 1100
? 1110
? 1111
! 1

result:

ok Correct answer with 12 queries.

Test #2:

score: 0
Accepted
time: 1ms
memory: 3588kb

input:

2
0
0
0

output:

? 10
? 01
? 11
! 0

result:

ok Correct answer with 3 queries.

Test #3:

score: 0
Accepted
time: 1ms
memory: 3596kb

input:

4
1
3
2
2
0
2
2
2
2
2
1
0

output:

? 1000
? 0100
? 0010
? 0001
? 1111
? 1100
? 1100
? 1010
? 1001
? 1100
? 1110
? 1111
! 1

result:

ok Correct answer with 12 queries.

Test #4:

score: 0
Accepted
time: 0ms
memory: 3560kb

input:

2
0
0
0

output:

? 10
? 01
? 11
! 0

result:

ok Correct answer with 3 queries.

Test #5:

score: 0
Accepted
time: 1ms
memory: 3788kb

input:

50
3
1
1
1
1
4
3
1
1
2
3
3
2
1
2
4
3
1
1
1
2
4
1
3
1
4
3
2
2
2
4
2
2
1
1
2
1
2
4
1
1
3
3
3
6
2
1
3
2
3
0
15
15
11
6
11

output:

? 10000000000000000000000000000000000000000000000000
? 01000000000000000000000000000000000000000000000000
? 00100000000000000000000000000000000000000000000000
? 00010000000000000000000000000000000000000000000000
? 00001000000000000000000000000000000000000000000000
? 000001000000000000000000000000000...

result:

ok Correct answer with 56 queries.

Test #6:

score: 0
Accepted
time: 3ms
memory: 3608kb

input:

50
10
13
8
6
13
8
10
8
8
8
9
13
15
11
9
10
14
6
16
10
15
10
7
8
10
10
10
13
10
15
9
10
11
5
16
10
14
11
10
9
9
15
11
10
7
11
12
10
9
10
0
25
36
33
22
19
25
36
33
22
19
25
36
33
22
14
25
36
33
22
13
25
36
33
29
22
25
36
33
25
17
25
36
33
25
17
25
36
33
25
17
25
36
33
25
18
23
18
25
36
33
26
17
25
36
...

output:

? 10000000000000000000000000000000000000000000000000
? 01000000000000000000000000000000000000000000000000
? 00100000000000000000000000000000000000000000000000
? 00010000000000000000000000000000000000000000000000
? 00001000000000000000000000000000000000000000000000
? 000001000000000000000000000000000...

result:

ok Correct answer with 356 queries.

Test #7:

score: 0
Accepted
time: 0ms
memory: 3616kb

input:

50
1
3
1
4
3
1
1
1
1
3
1
1
1
1
3
5
1
1
1
1
3
2
5
1
2
1
4
1
2
3
4
3
3
2
3
1
1
1
1
3
2
2
1
3
4
2
4
2
3
2
0
17
17
14
8
5
2
5

output:

? 10000000000000000000000000000000000000000000000000
? 01000000000000000000000000000000000000000000000000
? 00100000000000000000000000000000000000000000000000
? 00010000000000000000000000000000000000000000000000
? 00001000000000000000000000000000000000000000000000
? 000001000000000000000000000000000...

result:

ok Correct answer with 58 queries.

Test #8:

score: -100
Wrong Answer
time: 2ms
memory: 3780kb

input:

50
2
14
8
8
7
12
12
8
8
9
9
10
8
8
4
8
9
9
9
11
13
11
8
7
9
12
7
5
6
4
7
8
10
5
5
10
8
4
10
9
11
7
10
8
6
8
10
7
5
9
0
25
31
33
24
15
25
31
33
24
15
25
31
33
24
10
23
20
25
31
33
24
10
23
18
25
31
33
24
9
23
17
25
31
33
26
14
25
23
25
31
33
28
14
27
22
25
31
32
26
10
25
19
25
31
32
25
10
24
19
25
31...

output:

? 10000000000000000000000000000000000000000000000000
? 01000000000000000000000000000000000000000000000000
? 00100000000000000000000000000000000000000000000000
? 00010000000000000000000000000000000000000000000000
? 00001000000000000000000000000000000000000000000000
? 000001000000000000000000000000000...

result:

wrong answer Wrong answer.