QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#774313#9783. Duloc Networkucup-team3555#RE 8ms4232kbC++201.2kb2024-11-23 12:56:562024-11-23 12:56:57

Judging History

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

  • [2024-11-23 12:56:57]
  • 评测
  • 测评结果:RE
  • 用时:8ms
  • 内存:4232kb
  • [2024-11-23 12:56:56]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;

typedef long long ll;
const int N=203;
int n,tot,f[N],ans[N];
map<vector<int>,int>mp;
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;
	if(mp.count(vis))return mp[vis];
	cout<<"? ";
	for(int i=1;i<=n;i++)cout<<vis[i];
	cout<<endl;
	if(++tot>=3500)assert(0);
	int s;cin>>s;return mp[vis]=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});
	int tim=0;
	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++)
		{
			for(int j=0;j<sz;j++)if(j!=i&&Ask({ve[i],ve[j]})<ans[ve[i]]+ans[ve[j]])
				nb.push_back({ve[i],ve[j]});
		}
		for(auto t:nb)Mer(t[0],t[1]);
		if(++tim>100)NB(0);
	}
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

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

output:

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

result:

ok Correct answer with 12 queries.

Test #2:

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

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: 3548kb

input:

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

output:

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

result:

ok Correct answer with 12 queries.

Test #4:

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

input:

2
0
0
0

output:

? 10
? 01
? 11
! 0

result:

ok Correct answer with 3 queries.

Test #5:

score: 0
Accepted
time: 5ms
memory: 3948kb

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
4
4
4
4
7
6
4
4
5
6
6
3
4
5
7
6
4
4
4
5
7
4
6
4
7
6
4
4
5
5
5
5
4
4
5
4
5
7
4
4
4
5
6
8
4
4
6
5
5
2
2
2
5
2
2
2
3
4
4
3
1
3
5
4
2
2
2
3
5
2
4
2
5
4
3
3
3
5
3
3
2
2
2
2
3
5
2
2
4
4
4
7
3
2
4
3
4
2...

output:

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

result:

ok Correct answer with 1316 queries.

Test #6:

score: 0
Accepted
time: 7ms
memory: 4020kb

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
19
14
13
22
17
17
17
18
17
17
18
22
18
18
16
20
15
23
18
18
17
16
17
17
19
18
21
18
23
17
20
19
12
23
19
21
21
16
17
18
22
15
16
16
17
18
17
18
17
19
16
24
20
19
...

output:

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

result:

ok Correct answer with 1323 queries.

Test #7:

score: 0
Accepted
time: 8ms
memory: 3928kb

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
4
2
5
4
2
2
2
2
4
2
2
2
2
4
5
2
2
2
2
4
3
6
2
3
2
5
2
3
4
5
4
4
3
4
2
2
2
2
4
1
3
2
4
5
3
5
3
4
3
4
7
6
4
4
4
4
5
4
4
4
4
6
7
4
4
4
4
6
5
5
4
5
4
6
4
5
6
4
6
6
5
5
4
4
4
4
6
5
5
3
6
7
5
3
5
6
4
5...

output:

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

result:

ok Correct answer with 1312 queries.

Test #8:

score: 0
Accepted
time: 7ms
memory: 4232kb

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
15
10
10
9
14
14
10
10
10
11
12
10
10
6
10
11
11
11
13
15
13
10
9
11
14
8
5
7
6
9
10
12
7
7
12
10
4
12
11
13
9
11
9
8
10
11
9
7
11
20
18
17
23
22
19
19
17
19
18
20
21
18
18
20
22
20...

output:

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

result:

ok Correct answer with 1323 queries.

Test #9:

score: 0
Accepted
time: 7ms
memory: 3932kb

input:

50
3
1
1
1
2
1
1
1
1
5
1
2
1
1
1
1
3
1
1
2
1
1
1
2
2
1
1
1
1
3
1
2
1
1
2
3
1
2
3
2
1
3
1
2
3
1
2
2
1
1
0
4
4
2
3
4
4
4
4
8
4
5
4
4
4
4
6
4
2
5
4
4
4
5
5
4
3
4
4
6
4
5
4
4
5
6
4
5
6
5
4
6
4
5
6
4
5
5
4
4
2
2
3
2
2
2
2
5
2
3
2
2
2
2
4
2
2
3
2
2
2
3
3
2
2
2
2
4
2
3
2
2
3
3
2
3
2
3
2
4
2
3
4
2
3
3
2
2
2...

output:

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

result:

ok Correct answer with 1306 queries.

Test #10:

score: -100
Runtime Error

input:

100
1
2
1
1
1
1
1
1
3
3
1
1
2
3
4
1
2
2
2
1
2
2
1
2
2
1
1
1
3
2
1
2
2
1
4
1
1
1
3
2
4
1
3
2
3
3
3
1
1
1
1
2
1
2
2
4
3
1
2
1
1
1
1
3
3
3
2
1
1
2
1
2
2
3
2
1
5
3
5
1
1
1
1
1
1
1
1
3
4
1
2
1
2
1
1
2
1
3
2
1
0
3
2
2
2
2
2
2
4
4
2
2
3
4
5
2
3
3
3
2
3
3
2
3
3
2
2
2
4
3
2
3
3
2
5
2
2
2
4
3
5
2
4
3
4
4
4
2
...

output:

? 1000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
? 0100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
? 00100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...

result: