답안 #267207

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
267207 2020-08-16T01:20:47 Z Shisuko 도서관 (JOI18_library) C++14
0 / 100
143 ms 384 KB
#include <cstdio>
#include <chrono>
#include <random>
#include <algorithm>
#include <vector>
#include <iostream>
#include "library.h"
using namespace std;

void Solve(int N)
{
	mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
	vector<int> M(N);

	vector<int> end_point_guesses(N);
	iota(end_point_guesses.begin(), end_point_guesses.end(),0);
	shuffle(end_point_guesses.begin(),end_point_guesses.end(), rng);

	vector<int> res(N);
	for(const int& guess: end_point_guesses) 
	{
		for(int i = 0; i < N; i++)
			M[i] = i==guess ? 0 : 1;

		if(Query(M)==1)
		{
			res[0] = guess;
			break;
		}
	}
	vector<int> done(N,false);
	done[res[0]] = true;

	for(int i = 1; i < N; i++)
	{
		vector<int> candidates; candidates.reserve(N-i);
		for(int g = 0; g < N; g++)
			if(!done[g])
				candidates.push_back(g);
		shuffle(candidates.begin(),candidates.end(), rng);
		for(const int& guess : candidates)
		{
			for(int g = 0; g < N; g++)
				M[g] = g==res[i-1] || g==guess ? 1 : 0;
			if(Query(M)==1)
			{
				res[i] = guess;
				done[guess] = true;
				break;
			}
		}
	}
	for(int& g : res)
		++g;
	Answer(res);
}
# 결과 실행 시간 메모리 Grader output
1 Correct 110 ms 256 KB # of queries: 8868
2 Correct 143 ms 256 KB # of queries: 9463
3 Correct 140 ms 256 KB # of queries: 9690
4 Correct 120 ms 384 KB # of queries: 10371
5 Correct 142 ms 256 KB # of queries: 10729
6 Correct 130 ms 256 KB # of queries: 9562
7 Correct 128 ms 256 KB # of queries: 10717
8 Correct 109 ms 256 KB # of queries: 9601
9 Correct 132 ms 256 KB # of queries: 10093
10 Correct 73 ms 256 KB # of queries: 4508
11 Incorrect 0 ms 256 KB Wrong Answer [2]
12 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 110 ms 256 KB # of queries: 8868
2 Correct 143 ms 256 KB # of queries: 9463
3 Correct 140 ms 256 KB # of queries: 9690
4 Correct 120 ms 384 KB # of queries: 10371
5 Correct 142 ms 256 KB # of queries: 10729
6 Correct 130 ms 256 KB # of queries: 9562
7 Correct 128 ms 256 KB # of queries: 10717
8 Correct 109 ms 256 KB # of queries: 9601
9 Correct 132 ms 256 KB # of queries: 10093
10 Correct 73 ms 256 KB # of queries: 4508
11 Incorrect 0 ms 256 KB Wrong Answer [2]
12 Halted 0 ms 0 KB -