Submission #656586

# Submission time Handle Problem Language Result Execution time Memory
656586 2022-11-08T02:09:19 Z haojiandan Library (JOI18_library) C++14
100 / 100
443 ms 312 KB
#include <bits/stdc++.h>
#include "library.h"
using namespace std;

int n,p[1010],tot;
int d[1010],vis[1010];
void Solve(int _n) {
	n=_n;
	if (n==1) { Answer({1}); return; }
	int x=-1;
	for (int i=1;i<=n;i++) {
		vector<int> Q(n);
		for (int j=1;j<=n;j++) Q[j-1]=1;
		Q[i-1]=0;
		if (Query(Q)==1) { x=i; break; }
	}
	d[1]=x,vis[x]=1;
	for (int i=2;i<=n;i++) {
		tot=0;
		for (int j=1;j<=n;j++) if (!vis[j]) p[++tot]=j;
		if (tot==1) { d[i]=p[1]; continue; }
		int l=1,r=tot,mid,res=-1;
		while (l<=r) {
			vector<int> Q(n);
			for (int j=1;j<=n;j++) Q[j-1]=0;
			int mid=(l+r)>>1;
			for (int j=1;j<=mid;j++) Q[p[j]-1]=1;
			int tmp=Query(Q);
			Q[d[i-1]-1]=1;
			tmp=abs(tmp-Query(Q));
			if (tmp==0) res=mid,r=mid-1; else l=mid+1;
		}
		assert(res!=-1);
		x=p[res];
		d[i]=x,vis[x]=1;
	}
	vector<int> ans(n);
	for (int i=1;i<=n;i++) ans[i-1]=d[i];
	Answer(ans);
}

Compilation message

library.cpp: In function 'void Solve(int)':
library.cpp:22:17: warning: unused variable 'mid' [-Wunused-variable]
   22 |   int l=1,r=tot,mid,res=-1;
      |                 ^~~
# Verdict Execution time Memory Grader output
1 Correct 30 ms 208 KB # of queries: 2399
2 Correct 37 ms 208 KB # of queries: 2435
3 Correct 28 ms 208 KB # of queries: 2656
4 Correct 40 ms 208 KB # of queries: 2595
5 Correct 40 ms 208 KB # of queries: 2524
6 Correct 23 ms 208 KB # of queries: 2563
7 Correct 36 ms 208 KB # of queries: 2554
8 Correct 43 ms 208 KB # of queries: 2422
9 Correct 39 ms 208 KB # of queries: 2548
10 Correct 16 ms 208 KB # of queries: 1486
11 Correct 0 ms 208 KB # of queries: 0
12 Correct 0 ms 208 KB # of queries: 1
13 Correct 0 ms 208 KB # of queries: 4
14 Correct 1 ms 208 KB # of queries: 7
15 Correct 1 ms 208 KB # of queries: 77
16 Correct 2 ms 208 KB # of queries: 193
# Verdict Execution time Memory Grader output
1 Correct 30 ms 208 KB # of queries: 2399
2 Correct 37 ms 208 KB # of queries: 2435
3 Correct 28 ms 208 KB # of queries: 2656
4 Correct 40 ms 208 KB # of queries: 2595
5 Correct 40 ms 208 KB # of queries: 2524
6 Correct 23 ms 208 KB # of queries: 2563
7 Correct 36 ms 208 KB # of queries: 2554
8 Correct 43 ms 208 KB # of queries: 2422
9 Correct 39 ms 208 KB # of queries: 2548
10 Correct 16 ms 208 KB # of queries: 1486
11 Correct 0 ms 208 KB # of queries: 0
12 Correct 0 ms 208 KB # of queries: 1
13 Correct 0 ms 208 KB # of queries: 4
14 Correct 1 ms 208 KB # of queries: 7
15 Correct 1 ms 208 KB # of queries: 77
16 Correct 2 ms 208 KB # of queries: 193
17 Correct 422 ms 208 KB # of queries: 18028
18 Correct 390 ms 208 KB # of queries: 17277
19 Correct 408 ms 208 KB # of queries: 17477
20 Correct 386 ms 208 KB # of queries: 16299
21 Correct 363 ms 312 KB # of queries: 15350
22 Correct 443 ms 304 KB # of queries: 17661
23 Correct 399 ms 304 KB # of queries: 17248
24 Correct 93 ms 208 KB # of queries: 7915
25 Correct 331 ms 312 KB # of queries: 17156
26 Correct 340 ms 208 KB # of queries: 16001
27 Correct 145 ms 208 KB # of queries: 8044
28 Correct 329 ms 208 KB # of queries: 15973
29 Correct 388 ms 208 KB # of queries: 15955
30 Correct 383 ms 208 KB # of queries: 15973