답안 #656570

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
656570 2022-11-08T01:47:49 Z haojiandan 도서관 (JOI18_library) C++14
0 / 100
171 ms 324 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;
	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:23:6: warning: 'x' may be used uninitialized in this function [-Wmaybe-uninitialized]
   23 |  int x;
      |      ^
# 결과 실행 시간 메모리 Grader output
1 Correct 134 ms 320 KB # of queries: 9381
2 Correct 138 ms 312 KB # of queries: 9827
3 Correct 171 ms 316 KB # of queries: 10539
4 Correct 122 ms 324 KB # of queries: 10140
5 Correct 142 ms 320 KB # of queries: 10629
6 Correct 137 ms 316 KB # of queries: 10590
7 Correct 162 ms 208 KB # of queries: 10634
8 Correct 123 ms 312 KB # of queries: 10305
9 Correct 125 ms 324 KB # of queries: 10013
10 Correct 60 ms 208 KB # of queries: 4245
11 Incorrect 0 ms 208 KB Wrong Answer [5]
12 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 134 ms 320 KB # of queries: 9381
2 Correct 138 ms 312 KB # of queries: 9827
3 Correct 171 ms 316 KB # of queries: 10539
4 Correct 122 ms 324 KB # of queries: 10140
5 Correct 142 ms 320 KB # of queries: 10629
6 Correct 137 ms 316 KB # of queries: 10590
7 Correct 162 ms 208 KB # of queries: 10634
8 Correct 123 ms 312 KB # of queries: 10305
9 Correct 125 ms 324 KB # of queries: 10013
10 Correct 60 ms 208 KB # of queries: 4245
11 Incorrect 0 ms 208 KB Wrong Answer [5]
12 Halted 0 ms 0 KB -