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

Compiler report

In file included from /usr/include/c++/7/bits/hashtable.h:35:0,
                 from /usr/include/c++/7/unordered_set:47,
                 from input/code.cpp:3:
/usr/include/c++/7/bits/hashtable_policy.h: In instantiation of 'struct std::__detail::__is_noexcept_hash<std::vector<int>, std::hash<std::vector<int> > >':
/usr/include/c++/7/type_traits:143:12:   required from 'struct std::__and_<std::__is_fast_hash<std::hash<std::vector<int, std::allocator<int> > > >, std::__detail::__is_noexcept_hash<std::vector<int, std::allocator<int> >, std::hash<std::vector<int, std::allocator<int> > > > >'
/usr/include/c++/7/type_traits:154:31:   required from 'struct std::__not_<std::__and_<std::__is_fast_hash<std::hash<std::vector<int, std::allocator<int> > > >, std::__detail::__is_noexcept_hash<std::vector<int, std::allocator<int> >, std::hash<std::vector<int, std::allocator<int> > > > > >'
/usr/include/c++/7/bits/unordered_set.h:832:64:   required from 'class std::unordered_multiset<std::vector<i...

Code

#include <iostream>
#include <vector>
#include <unordered_set>
using namespace std;
unordered_multiset<vector<int>> m;
int main() {
int n, c = 0;
cin >> n;
string s;
for (int _ = 0; _ < n; _++) {
cin >> s;
vector<int> z;
for (int i = 0; i < s.size(); i++) {
z.push_back(i);
for (int j = 0; j < i; j++) {
if (s[i] == s[j]) z[i] = z[j];
}
}
if (m.count(z)) {
c += m.count(z);
}
m.insert(z);
}
cout << c << endl;
}