Submission #630214

# Submission time Handle Problem Language Result Execution time Memory
630214 2022-08-16T05:27:07 Z pooyashams Library (JOI18_library) C++14
0 / 100
41 ms 304 KB
#include <cstdio>
#include <vector>
#include "library.h"
using namespace std;

const int maxn = 1010;

int ans[maxn];
int n;

inline int bisect(int x)
{
	vector<int> c1(n, 0);
	vector<int> rem;
	for(int i = 0; i < x; i++)
		c1[ans[i]] = 1;
	for(int i = 0; i < n; i++)
		if(!c1[i])
			rem.push_back(i);
	int down = 0;
	int up = rem.size();
	while(up-down > 1)
	{
		int mid = (up+down) / 2;
		vector<int> m1 = c1;
		vector<int> m2(n, 0);
		for(int j = down; j < mid; j++)
		{
			m1[rem[j]] = 1;
			m2[rem[j]] = 1;
		}
		if(Query(m1) == Query(m2))
			up = mid;
		else
			down = mid;
	}
	return rem[down];
}

void Solve(int N)
{
	n = N;
	for(int i = 0; i < n; i++)
	{
		vector<int> m(n, 1);
		m[i] = 0;
		if(Query(m) == 1)
		{
			ans[0] = i;
			break;
		}
	}
	for(int i = 1; i < n; i++)
		ans[i] = bisect(i);
	vector<int> A(n);
	for(int i = 0; i < n; i++)
		A[i] = ans[i]+1;
	Answer(A);
}
# Verdict Execution time Memory Grader output
1 Correct 35 ms 208 KB # of queries: 2375
2 Correct 36 ms 300 KB # of queries: 2409
3 Correct 30 ms 208 KB # of queries: 2648
4 Correct 41 ms 208 KB # of queries: 2595
5 Correct 35 ms 208 KB # of queries: 2508
6 Correct 37 ms 208 KB # of queries: 2551
7 Correct 39 ms 208 KB # of queries: 2544
8 Correct 31 ms 208 KB # of queries: 2420
9 Correct 34 ms 208 KB # of queries: 2546
10 Correct 16 ms 304 KB # of queries: 1474
11 Runtime error 0 ms 208 KB Execution killed with signal 13
12 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 35 ms 208 KB # of queries: 2375
2 Correct 36 ms 300 KB # of queries: 2409
3 Correct 30 ms 208 KB # of queries: 2648
4 Correct 41 ms 208 KB # of queries: 2595
5 Correct 35 ms 208 KB # of queries: 2508
6 Correct 37 ms 208 KB # of queries: 2551
7 Correct 39 ms 208 KB # of queries: 2544
8 Correct 31 ms 208 KB # of queries: 2420
9 Correct 34 ms 208 KB # of queries: 2546
10 Correct 16 ms 304 KB # of queries: 1474
11 Runtime error 0 ms 208 KB Execution killed with signal 13
12 Halted 0 ms 0 KB -