Submission #656572

# Submission time Handle Problem Language Result Execution time Memory
656572 2022-11-08T01:48:50 Z haojiandan Library (JOI18_library) C++14
19 / 100
454 ms 452 KB
#include <bits/stdc++.h>
#include "library.h"
using namespace std;

int n,p[1010];
vector<int> g[1010];
int tot,d[1010];
void dfs(int u,int p) {
	d[++tot]=u;
	for (int &v : g[u]) if (v!=p) dfs(v,u);
}
void Solve(int _n) {
	n=_n;
	if (n==1) { Answer({1}); return; }
	for (int i=1;i<=n;i++) {
		for (int j=i+1;j<=n;j++) p[j]=j;
		random_shuffle(p+i+1,p+n+1);
		for (int j=i+1;j<=n&&(int)g[i].size()<2;j++) {
			vector<int> Q(n);
			Q[i-1]=Q[p[j]-1]=1;
			if (Query(Q)==1) g[i].push_back(p[j]),g[p[j]].push_back(i);
		}
	}
	int x;
	for (int i=1;i<=n;i++) if ((int)g[i].size()==1) { x=i; break; }
	dfs(x,0);
	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:26:5: warning: 'x' may be used uninitialized in this function [-Wmaybe-uninitialized]
   26 |  dfs(x,0);
      |  ~~~^~~~~
# Verdict Execution time Memory Grader output
1 Correct 123 ms 208 KB # of queries: 9381
2 Correct 126 ms 328 KB # of queries: 9827
3 Correct 92 ms 452 KB # of queries: 10539
4 Correct 137 ms 208 KB # of queries: 10140
5 Correct 124 ms 440 KB # of queries: 10629
6 Correct 177 ms 208 KB # of queries: 10590
7 Correct 142 ms 208 KB # of queries: 10634
8 Correct 149 ms 308 KB # of queries: 10305
9 Correct 111 ms 316 KB # of queries: 10013
10 Correct 51 ms 208 KB # of queries: 4245
11 Correct 0 ms 208 KB # of queries: 0
12 Correct 0 ms 208 KB # of queries: 1
13 Correct 1 ms 208 KB # of queries: 3
14 Correct 1 ms 208 KB # of queries: 5
15 Correct 1 ms 208 KB # of queries: 72
16 Correct 4 ms 208 KB # of queries: 236
# Verdict Execution time Memory Grader output
1 Correct 123 ms 208 KB # of queries: 9381
2 Correct 126 ms 328 KB # of queries: 9827
3 Correct 92 ms 452 KB # of queries: 10539
4 Correct 137 ms 208 KB # of queries: 10140
5 Correct 124 ms 440 KB # of queries: 10629
6 Correct 177 ms 208 KB # of queries: 10590
7 Correct 142 ms 208 KB # of queries: 10634
8 Correct 149 ms 308 KB # of queries: 10305
9 Correct 111 ms 316 KB # of queries: 10013
10 Correct 51 ms 208 KB # of queries: 4245
11 Correct 0 ms 208 KB # of queries: 0
12 Correct 0 ms 208 KB # of queries: 1
13 Correct 1 ms 208 KB # of queries: 3
14 Correct 1 ms 208 KB # of queries: 5
15 Correct 1 ms 208 KB # of queries: 72
16 Correct 4 ms 208 KB # of queries: 236
17 Runtime error 454 ms 320 KB Execution killed with signal 13
18 Halted 0 ms 0 KB -