제출 #108826

#제출 시각아이디문제언어결과실행 시간메모리
108826tictaccat도서관 (JOI18_library)C++11
0 / 100
3097 ms420 KiB
#include <cstdio>
#include <vector>
#include "library.h"
#include <bits/stdc++.h>
using namespace std;

void Solve(int N)
{

	srand(time(0));

	vector<int> M(N,1), indices(N);

	iota(indices.begin(),indices.end(),0);
	random_shuffle(indices.begin(),indices.end());

	vector<int> res(N);
	vector<bool> found(N);

	for (res[0] = 0; res[0] < N; res[0]++) {
		M[res[0]] = 0;
		if (Query(M) == 1) {
			found[res[0]] = true;
			break;
		}
		M[res[0]] = 1;
	}

	M = vector<int>(N,0);
	M[res[0]] = 1;

	for (int k = 1; k < N; k++) {
		for (int i: indices) {
			if (found[i]) continue;
			M[i] = 1;
			if (Query(M) == 1) {
				res[k] = i;
				found[i] = true;
				break;
			}
			M[i] = 0;
		}
	}

	// for (int i = 0; i < N; i++) {
	// 	res[i]++;
	// 	cout << res[i] << " ";
	// }

	// cout << "\n";

	Answer(res);
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...