CSES - Datatähti 2020 alku - Results
Submission details
Task:Merkkijonot
Sender:pants64
Submission time:2019-10-01 15:43:03 +0300
Language:C++17
Status:COMPILE ERROR

Compiler report

input/code.cpp: In function 'int main()':
input/code.cpp:40:19: error: no matching function for call to 'std::vector<std::vector<unsigned char> >::resize(int&, int)'
  lines.resize(n, 0);
                   ^
In file included from /usr/include/c++/7/vector:64:0,
                 from input/code.cpp:2:
/usr/include/c++/7/bits/stl_vector.h:689:7: note: candidate: void std::vector<_Tp, _Alloc>::resize(std::vector<_Tp, _Alloc>::size_type) [with _Tp = std::vector<unsigned char>; _Alloc = std::allocator<std::vector<unsigned char> >; std::vector<_Tp, _Alloc>::size_type = long unsigned int]
       resize(size_type __new_size)
       ^~~~~~
/usr/include/c++/7/bits/stl_vector.h:689:7: note:   candidate expects 1 argument, 2 provided
/usr/include/c++/7/bits/stl_vector.h:709:7: note: candidate: void std::vector<_Tp, _Alloc>::resize(std::vector<_Tp, _Alloc>::size_type, const value_type&) [with _Tp = std::vector<unsigned char>; _Alloc = std::allocator<std::vector<unsigned char> >; std::vector<_Tp,...

Code

#include <iostream>
#include <vector>
#include <string>
#include <cstdint>

using std::cout, std::cin, std::vector, std::string;

vector<vector<uint8_t>> lines;

inline vector<uint8_t> Convert(const string& str)
{
	vector<uint8_t> line (str.length(), 0);

	uint8_t max = 0;
	for (unsigned i = 0; i < str.length(); i++)
	{
		bool found = false;
		for (unsigned j = 0; j < i; j++)
		{
			if (str[j] == str[i])
			{
				line[i] = line[j];
				found = true;

				if (max < line[i]) max = line[i];

				break;
			}
		}
		if (!found) line[i] = max++;
	}
	return line;
}

int main()
{
	int n;
	cin >> n;

	lines.resize(n, 0);

	for (int i = 0; i < n; i++)
	{
		string input;
		cin >> input;

		lines.push_back(Convert(input));
	}

	uint64_t num = 0;

	for (decltype(lines)::iterator i = lines.begin(); i != lines.end(); i++)
	{
		for (decltype(lines)::iterator j = i + 1; j != lines.end(); j++)
		{
			if (*i == *j) num++;
		}
	}
	cout << num << "\n";
}