Submission #1161755

#TimeUsernameProblemLanguageResultExecution timeMemory
1161755NurislamLibrary (JOI18_library)C++17
Compilation error
0 ms0 KiB
#include <bits/stdc++.h>
#include <cstdio>
#include "library.h"

#include "grader.cpp"

using namespace std;

void Solve(int n) {
	vector<deque<int>> lq, q;
	
	for(int i = 0; i < n; i ++ ){
		deque<int> res;
		res.push_back(i);
		lq.push_back(res);
	}
	
	auto ask = [&]( int &r, deque<int> &a) -> int{
		vector<int> res(n, 0);
		for(int i : a)res[i] = 1;
		for(int i = 0; i <= r; i ++ ){
			for(auto x : q[i])res[x] = 1;
		};
		//cout << l << ' ' << r << '\n';
		//for(int i : res)cout << i << ' ';
		//cout << '\n';
		//int x = 0;
		return Query(res);
	};
	
	auto pushit = [&] ( int &m, deque<int> &i ) -> void {
		assert(m < (int)q.size());
		//cout << "Pushit\n";
			//for(auto x : q[m])cout << x << ' ';
			//cout << '\n';
			//for(auto x : i) cout << x << ' ';
			//cout << '\n';
		
			vector<int> res(n, 0);
			res[i.front()] = 1;
			
			// front
				res[q[m].front()] = 1;
				if(Query(res) == 1){
					while(i.size()){
						q[m].push_front(i.front());
						i.pop_front();
					}
					return;
				};
				res[q[m].front()] = 0;
			// back
				res[q[m].back()] = 1;
				if(Query(res) == 1){
					while(i.size()){
						q[m].push_back(i.front());
						i.pop_front();
					}
					return;
				};
				res[q[m].back()] = 0;
			
			res[i.front()] = 0;
			
			
			res[i.back()] = 1;
			// front
				res[q[m].front()] = 1;
				if(Query(res) == 1){
					while(i.size()){
						q[m].push_front(i.back());
						i.pop_back();
					}
					return;
				};
				res[q[m].front()] = 0;
			// back
				res[q[m].back()] = 1;
				if(Query(res) == 1){
					while(i.size()){
						q[m].push_back(i.back());
						i.pop_back();
					}
					return;
				};
				res[q[m].back()] = 0;
	};
	
	while(lq.size() > 1){
		
		//for(auto &i : lq){
			//for(auto x : i)cout << x << ' ';
			//cout << '\n';
		//}
		//cout << '\n';
		
		vector<int> al(n, 0);
		for(deque<int> &res : lq){
			for(int &i : res)al[i] = 1;
			
			if(q.empty() || Query(al) > (int)q.size()){
				q.push_back(res);
				continue;
			}
			
			int l = 0, r = q.size() - 1;
			while(l < r) {
				int m = (l + r ) >> 1;
				
				if(ask( m, res ) <= m-l+1) r = m;
				else l = m + 1;
			};
			pushit( l, res );
		};
		swap(lq, q);
		q.clear();
		
		//break;
		//reverse(lq.begin(), lq.end());
	}
	vector<int> ans;
	for(int i : lq.front())ans.push_back(i+1);
	
	Answer(ans);
}

Compilation message (stderr)

/usr/bin/ld: /tmp/ccWtoDZn.o: in function `Query(std::vector<int, std::allocator<int> > const&)':
grader.cpp:(.text+0x0): multiple definition of `Query(std::vector<int, std::allocator<int> > const&)'; /tmp/ccCJR4SY.o:library.cpp:(.text+0x0): first defined here
/usr/bin/ld: /tmp/ccWtoDZn.o:(.bss+0x0): multiple definition of `__my_judge_::judge'; /tmp/ccCJR4SY.o:(.bss+0x0): first defined here
/usr/bin/ld: /tmp/ccWtoDZn.o: in function `Answer(std::vector<int, std::allocator<int> > const&)':
grader.cpp:(.text+0x20): multiple definition of `Answer(std::vector<int, std::allocator<int> > const&)'; /tmp/ccCJR4SY.o:library.cpp:(.text+0x20): first defined here
/usr/bin/ld: /tmp/ccWtoDZn.o: in function `main':
grader.cpp:(.text.startup+0x0): multiple definition of `main'; /tmp/ccCJR4SY.o:library.cpp:(.text.startup+0x0): first defined here
collect2: error: ld returned 1 exit status