| Task: | Merkkijonot |
| Sender: | removed5096 |
| Submission time: | 2019-10-07 22:26:23 +0300 |
| Language: | C++ (C++17) |
| Status: | SKIPPED |
Compiler report
input/code.cpp: In function 'bool areHarmonic(std::__cxx11::string, std::__cxx11::string)':
input/code.cpp:10:20: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for (int i = 0; i < s1.length(); i++)
~~^~~~~~~~~~~~~
input/code.cpp:12:25: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for (int j = i + 1; j < s1.length(); j++)
~~^~~~~~~~~~~~~Code
#include<iostream>
#include<vector>
#include<string>
bool areHarmonic(std::string s1, std::string s2)
{
if (s1.length() != s2.length())
return false;
for (int i = 0; i < s1.length(); i++)
{
for (int j = i + 1; j < s1.length(); j++)
{
if ((s1[i] == s1[j]) != (s2[i] == s2[j]))
return false;
}
}
return true;
}
int main()
{
int n;
std::cin >> n;
std::vector<std::string> v;
for (int i = 0; i < n; i++)
{
v.push_back(std::string());
std::cin >> v.back();
}
int count = 0;
for (int i = 0; i < n; i++)
{
for (int j = i+1; j < n; j++)
{
count += areHarmonic(v[i], v[j]);
}
}
std::cout << count;
return 0;
}