Submission #47200

# Submission time Handle Problem Language Result Execution time Memory
47200 2018-04-29T05:04:16 Z Kmcode Hidden Sequence (info1cup18_hidden) C++14
Compilation error
0 ms 0 KB
#include "bits/stdc++.h"
using namespace std;

bool isSubsequence(vector<int> S) {
	for (int el : S) {
		cout << el << " ";
	}
	cout << endl;
	int k;
	cin >> k;
	return k; 
}
vector<int> calc(vector<int> v, int add,int lim,int n) {
	vector<pair<int, int> > vv;
	vector<int> v1;
	for (int i = v.size(); i >= 0; i--) {
		vector<int> tmp;
		tmp = v;
		int z = 0;
		while (1) {
			tmp.insert(tmp.begin() + tmp.size() - i, add);
			if (tmp.size() > lim) {
				tmp.pop_back();
				break;
			}
			if (isSubsequence(tmp)) {

			}
			else {
				tmp.pop_back();
				break;
			}
			z++;
		}
		v1.push_back(z);
	}
	int sum = n-v.size();
	for (int el : v1) {
		sum -= el;
	}
	int id = max_element(v1.begin(), v1.end()) - v1.begin();
	v1[id] += sum;
	int z = v.size();
	for (int i = z; i >= 0; i--) {
		while (v1[z - i]--) {
			v.insert(v.begin() + v.size() - i, add);
		}
	}
	return v;
}
vector<int> findSequence(int N) {
	vector<int> zero;
	vector<int> one;
	for (int i = 0; i < N/2 +1; i++) {
		zero.push_back(0);
		one.push_back(1);
		if (isSubsequence(zero)) {

		}
		else{
			zero.pop_back();
		}
		if (!isSubsequence(one)) {
			one.pop_back();
		}
	}
	while (zero.size() + one.size() < N) {
		if (zero.size() > one.size()) {
			one.push_back(1);
		}
		else {
			zero.push_back(0);
		}
	}
	if (one.size() > zero.size()) {
		return calc(zero, 1, (3 * N) / 4 + 1, N);
	}
	else {
		return calc(one, 0, (3 * N) / 4 + 1, N);
	}
}
int main() {
	int n;
	cin >> n;
	vector<int> ans=findSequence(n);
	for (int el : ans) {
		cout << el << " ";
	}
	return 0;
}

Compilation message

hidden.cpp: In function 'std::vector<int> calc(std::vector<int>, int, int, int)':
hidden.cpp:22:19: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
    if (tmp.size() > lim) {
        ~~~~~~~~~~~^~~~~
hidden.cpp: In function 'std::vector<int> findSequence(int)':
hidden.cpp:67:34: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  while (zero.size() + one.size() < N) {
         ~~~~~~~~~~~~~~~~~~~~~~~~~^~~
grader.cpp: In function 'int main()':
grader.cpp:28:43: warning: format '%d' expects argument of type 'int', but argument 3 has type 'std::vector<int>::size_type {aka long unsigned int}' [-Wformat=]
     fprintf (fifo_out, "%d\n", ans.size ());
                                ~~~~~~~~~~~^
grader.cpp:29:20: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for (int i=0; i<ans.size () && i < N; i++)
                   ~^~~~~~~~~~~~
/tmp/cc8quhU8.o: In function `isSubsequence(std::vector<int, std::allocator<int> >)':
grader.cpp:(.text+0x0): multiple definition of `isSubsequence(std::vector<int, std::allocator<int> >)'
/tmp/ccARU9ym.o:hidden.cpp:(.text+0x0): first defined here
/tmp/cc8quhU8.o: In function `main':
grader.cpp:(.text.startup+0x0): multiple definition of `main'
/tmp/ccARU9ym.o:hidden.cpp:(.text.startup+0x0): first defined here
collect2: error: ld returned 1 exit status