| Task: | Merkkijonot |
| Sender: | Kameli |
| Submission time: | 2019-10-09 12:21:55 +0300 |
| Language: | C++ (C++17) |
| Status: | COMPILE ERROR |
Compiler report
input/code.cpp: In function 'int main()':
input/code.cpp:22:30: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for (long long j=0; j<arr[i].length();j++){
~^~~~~~~~~~~~~~~~
input/code.cpp:32:9: error: 'sort' was not declared in this scope
sort(l.begin(), l.end());
^~~~
input/code.cpp:32:9: note: suggested alternative: 'qsort'
sort(l.begin(), l.end());
^~~~
qsort
input/code.cpp:33:22: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for(int j=0;j<l.size();j++){
~^~~~~~~~~
input/code.cpp:34:32: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for(long long k=0;k<l[j].size();k++){
~^~~~~~~~~~~~Code
#include <iostream>
#include <set>
#include <vector>
#include <string>
#include <map>
#include <unordered_set>
using namespace std;
int main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
long long n;
cin>>n;
string arr[n];
map<string,long long> m;
for(long long i=0;i<n;i++){
cin>>arr[i];
}
for(long long i=0; i<n; i++){
map<char,vector<long long>> us;
for (long long j=0; j<arr[i].length();j++){
us[arr[i][j]].push_back(j);
}
string harmony_hash = to_string(arr[i].length())+":";
vector<vector<long long>> l;
for(auto const& it : us){
if(it.second.size()>1){
l.push_back(it.second);
}
}
sort(l.begin(), l.end());
for(int j=0;j<l.size();j++){
for(long long k=0;k<l[j].size();k++){
harmony_hash.append(to_string(l[j][k])+",");
}
harmony_hash.append(":");
}
//cout<<harmony_hash<<"\n";
++m[harmony_hash];
}
long long c=0;
for(auto const& it : m){
c=c+it.second*(it.second-1)/2;
}
cout<<c<<"\n";
}
