CSES - Datatähti 2020 alku - Results
Submission details
Task:Merkkijonot
Sender:intoo
Submission time:2019-09-30 11:26:20 +0300
Language:C++ (C++17)
Status:COMPILE ERROR

Compiler report

input/code.cpp: In function 'int main()':
input/code.cpp:20:21: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   for (int i = 0; i < s.size(); i++) {
                   ~~^~~~~~~~~~
input/code.cpp:24:21: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   for (int i = 0; i < m.size(); i++) {
                   ~~^~~~~~~~~~
input/code.cpp:26:14: error: '__gnu_cxx::__alloc_traits<std::allocator<std::pair<std::vector<int>, int> > >::value_type {aka struct std::pair<std::vector<int>, int>}' has no member named 'push_back'
    else m[i].push_back({z, 1});
              ^~~~~~~~~
input/code.cpp:29:20: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for (int i = 0; i < m.size(); i++) {
                  ~~^~~~~~~~~~
input/code.cpp:31:12: error: no match for 'operator-' (operand types are 'std::vector<std::pair<std::vector<int>, int> >' and 'int')
   c += m*(m-1)/2;
           ~^~...

Code

#include <iostream>
#include <vector>
#include <set>

using namespace std;

int t[101010][26];

vector<pair<vector<int>, int>> m;
//multiset<vector<int>> m;

int main() {
	int n, c = 0;
	cin >> n;
	string s;
	for (int k = 0; k < n; k++) {
		cin >> s;
		vector<int> z;
		int x = 1;
		for (int i = 0; i < s.size(); i++) {
			if (!t[k][s[i]-65]) t[k][s[i]-65] = x++;
			z.push_back(t[k][s[i]-65]);
		}
		for (int i = 0; i < m.size(); i++) {
			if (m[i].first == z) m[i].second++;
			else m[i].push_back({z, 1});
		}
	}
	for (int i = 0; i < m.size(); i++) {
		int n = m[i].second;
		c += m*(m-1)/2;
	}
	cout << c << endl;
}