Created
June 14, 2019 13:00
-
-
Save Thiago4532/e868d4de27290037611093f5f786dc79 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Solucao Intermediário Semana 59 - Anagramas | |
// Thiago Mota | |
#include <bits/stdc++.h> | |
using namespace std; | |
const int maxn = 100010; | |
map<string, int> freq; | |
string str[maxn]; | |
int main() { | |
int n; | |
cin >> n; | |
for(int i = 1; i <= n; i++) { | |
string str; | |
cin >> str; // Ler a palavra; | |
sort(str.begin(), str.end()); // Ordernar a palavra pelas letras (roma = amor, dcba = abcd) | |
freq[str]++; // Aumenta a frequencia da palavra | |
} | |
int ans = 0; // Maior frequencia | |
for(map<string, int>::iterator it = freq.begin(); it != freq.end(); it++) { // Olhar para cada palavra armazenada em freq | |
string s = (*it).first; // Palavra armazenada | |
int f = (*it).second; // Frequencia da palavra | |
if(f > ans) { | |
ans = f; // Se a frequencia da palavra s for maior que a resposta, atualiza a resposta | |
} | |
} | |
cout << ans << "\n"; | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment