CSES - Datatähti 2021 alku - Results
Submission details
Task:Alitaulukot
Sender:_Ahrou
Submission time:2020-10-01 10:56:13 +0300
Language:C++ (C++11)
Status:COMPILE ERROR

Compiler report

input/code.cpp:4:10: fatal error: algoritim: No such file or directory
 #include <algoritim>
          ^~~~~~~~~~~
compilation terminated.

Code

#include <iostream>
#include <vector>
#include <cmath>
#include <algoritim>

std::vector<std::vector<int>> get_sub_tables(std::vector<int>& table, int difference)
{
	std::vector<std::vector<int>> sub_tables;
	for (auto i : table)
	{
		std::vector<int> temp;
		temp.emplace_back(i);
		if(std::find(sub_tables.begin(), sub_tables.end(), temp) == std::end(sub_tables))
			sub_tables.emplace_back(temp);
		
	}
	for (auto start_e = table.begin(); start_e != table.end(); ++start_e)
	{
		auto min = start_e;
		for (auto cur_e = start_e + 1; cur_e != table.end(); ++cur_e)
		{
			int res = *min - *cur_e;
			if (std::abs(res) <= difference)
			{
				std::vector<int> temp;
				for (auto i = start_e; i != cur_e + 1; ++i)
				{
					temp.emplace_back(*i);	
				}
				if(std::find(sub_tables.begin(), sub_tables.end(), temp) == std::end(sub_tables))
					sub_tables.emplace_back(temp);
			}
			else
			{
				break;
			}
		}
	}
	return sub_tables;
}
void print_tables(const std::vector<std::vector<int>>& source)
{
	for (auto table : source)
	{
		std::cout << "[ ";
		for (auto element : table)
		{
			std::cout << element << " ";
		}
		std::cout << "]";
	}
}
int main()
{
	int n;
	int d;
	std::vector<int> table;
	std::cin >> n;
	std::cin >> d;
	for (int i = 0; i < n; i++)
	{
		int temp;
		std::cin >> temp;
		table.emplace_back(temp);
	}
	auto sub_tables = get_sub_tables(table, d);
	//print_tables(sub_tables);
	std::cout << sub_tables.size();

	return 0;
}