Submission #344044

# Submission time Handle Problem Language Result Execution time Memory
344044 2021-01-05T05:03:01 Z tengiz05 Library (JOI18_library) C++17
Compilation error
0 ms 0 KB
#include <bits/stdc++.h>
#include "library.h"
#include "grader.cpp"
using namespace std;
void Solve(int n){
	if(n == 1){
		vector<int> ans = {1};
		Answer(ans);
		return;
	}
	vector<int> haha(n,0);
	for(int i=0;i<n;i++)haha[i] = i;
	mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
	int seed_for = uniform_int_distribution<int>(0,1000000000)(rng);
	shuffle(haha.begin(), haha.end(), default_random_engine(seed_for));
	vector<vector<int>> v(n);
	for(int i=0;i<n;i++){
		int I = haha[i];
		if(v[I].size() == 2)continue;
		vector<int> ask(n, 0);
		ask[I] = 1;
		for(int j=i+1;j<n;j++){
			int J = haha[j];
			if(v[J].size() == 2)continue;
			ask[J] = 1;
			if(Query(ask) == 1)v[I].push_back(J), v[J].push_back(I);
			ask[J] = 0;
		}
	}
	//~ for(int i=0;i<n;i++){for(auto x : v[i])cout << x << ' ';cout << '\n';}
	vector<bool> used(n);
	vector<int> ans;
	int u=-1;
	for(int i=0;i<n;i++){
		if(v[i].size() == 1){
			u = i;break;
		}
	}
	assert(u != -1);
	while(true){
		bool ch = false;
		used[u] = true;
		ans.push_back(u+1);
		for(auto to : v[u]){
			if(!used[to]){
				ch=true;
				u=to;
			}
		}if(!ch)break;
	}
	Answer(ans);
	return;
}

/*

5
4 2 5 3 1

*/

Compilation message

/tmp/cccd8i1v.o: In function `Query(std::vector<int, std::allocator<int> > const&)':
library.cpp:(.text+0x0): multiple definition of `Query(std::vector<int, std::allocator<int> > const&)'
/tmp/ccKVBhTJ.o:grader.cpp:(.text+0x0): first defined here
/tmp/cccd8i1v.o:(.bss+0x0): multiple definition of `__my_judge_::judge'
/tmp/ccKVBhTJ.o:(.bss+0x0): first defined here
/tmp/cccd8i1v.o: In function `Answer(std::vector<int, std::allocator<int> > const&)':
library.cpp:(.text+0x10): multiple definition of `Answer(std::vector<int, std::allocator<int> > const&)'
/tmp/ccKVBhTJ.o:grader.cpp:(.text+0x390): first defined here
/tmp/cccd8i1v.o: In function `main':
library.cpp:(.text.startup+0x0): multiple definition of `main'
/tmp/ccKVBhTJ.o:grader.cpp:(.text.startup+0x0): first defined here
collect2: error: ld returned 1 exit status