CSES - Datatähti 2018 alku - Results
Submission details
Task:Bittijono
Sender:SeveriK
Submission time:2017-10-06 09:04:12 +0300
Language:C++
Status:COMPILE ERROR

Compiler report

input/code.cpp: In function 'int main()':
input/code.cpp:141:72: error: no matching function for call to 'max(std::basic_string<char>::size_type, unsigned int)'
   vector<unsigned int>last(max(sequence.length() * 8, (unsigned int)128), -1);
                                                                        ^
input/code.cpp:141:72: note: candidates are:
In file included from /usr/include/c++/4.8/bits/char_traits.h:39:0,
                 from /usr/include/c++/4.8/ios:40,
                 from /usr/include/c++/4.8/ostream:38,
                 from /usr/include/c++/4.8/iostream:39,
                 from input/code.cpp:113:
/usr/include/c++/4.8/bits/stl_algobase.h:216:5: note: template<class _Tp> const _Tp& std::max(const _Tp&, const _Tp&)
     max(const _Tp& __a, const _Tp& __b)
     ^
/usr/include/c++/4.8/bits/stl_algobase.h:216:5: note:   template argument deduction/substitution failed:
input/code.cpp:141:72: note:   deduced conflicting types for parameter 'const _Tp' ('long unsign...

Code

/*
#include <iostream>
#include <fstream>
#include <string>
#include <vector>

using namespace std;

int main()
{
	string rows[10];
	for (int i = 0; i < 10; i++)
	{
		for (int o = 0; o < 10; o++)
		{
			int n = i + o;
			n = i + o;
			while (n > 9)
			{
				n -= 10;
			}
			rows[i] += to_string(n);

			if (i < 10 / 2)
			{
				n = o - i;
				while (n < 0)
				{
					n += 10;
				}
			}
			else
			{
				n = o - i + 1;
				while (n < 0)
				{
					n += 10;
				}
			}

			if (n == 0)
			{
				rows[i] += "A";
			}
			else if (n == 1)
			{
				rows[i] += "B";
			}
			else if (n == 2)
			{
				rows[i] += "C";
			}
			else if (n == 3)
			{
				rows[i] += "D";
			}
			else if (n == 4)
			{
				rows[i] += "E";
			}
			else if (n == 5)
			{
				rows[i] += "F";
			}
			else if (n == 6)
			{
				rows[i] += "G";
			}
			else if (n == 7)
			{
				rows[i] += "H";
			}
			else if (n == 8)
			{
				rows[i] += "I";
			}
			else if (n == 9)
			{
				rows[i] += "J";
			}
			if (o != 9)
			{
				rows[i] += " ";
			}
		}
		cout << rows[i] << "\n";
	}

	ofstream myfile;
	myfile.open("Eppapeli.txt");
	if (myfile.is_open())
	{
		for (int i = 0; i < 10; i++)
		{
			if (i != 10 - 1)
			{
				myfile << rows[i] + "\n";
			}
			else
			{
				myfile << rows[i];
			}
		}
		myfile.close();
	}

	int a;
	cin >> a;

	return 0;
}*/

#include <iostream>
#include <string>
#include <vector>
#include <bitset>
#include <algorithm>
using namespace std;

const int SEQUENCE_BITS = 128;

int main()
{
	unsigned int k = 0;
	cin >> k;

	unsigned int subCount = 0;
	unsigned int i = 0;
	if (k > 100)
	{
		i = k;
	}
	bitset<SEQUENCE_BITS> bitSequence(0);
	string sequence = "";
	while (subCount != k)
	{
		i++;
		bitSequence = bitset<SEQUENCE_BITS>(i);
		sequence = to_string(stoull(bitSequence.to_string()));

		vector<unsigned int>last(max(sequence.length() * 8, (unsigned int)128), -1);

		const unsigned int n = sequence.length();

		unsigned int* dp = new unsigned int[n + 1];
		dp[0] = 1;

		for (unsigned int i = 1; i <= n; i++)
		{
			dp[i] = 2 * dp[i - 1];

			if (last[sequence[i - 1]] != (unsigned int)-1)
			{
				dp[i] = dp[i] - dp[last[sequence[i - 1]]];
			}

			last[sequence[i - 1]] = (i - 1);
		}
		subCount = dp[n] - 1;
	}
	cout << sequence << "\n";

	int a = 0;
	cin >> a;
	return 0;
}