Skip to content

Instantly share code, notes, and snippets.

@orendon
Created December 3, 2020 03:29
Show Gist options
  • Save orendon/e0c70bb41b00e4f498745e073a6a0bcb to your computer and use it in GitHub Desktop.
Save orendon/e0c70bb41b00e4f498745e073a6a0bcb to your computer and use it in GitHub Desktop.
Equivalente en C++ a Python, Problema: https://codeforces.com/problemset/problem/1397/A
#include <iostream> // imports
#include <string>
#include <map>
using namespace std;
// Problema: https://codeforces.com/problemset/problem/1397/A
int main() {
int t, n;
string word;
cin >> t;
// Equivalente en Python
while(t--){
cin >> n;
map<char, int> mapa; // { }
for(int i=0; i<n; i++){ // for i in range(n)
cin >> word;
for(char s : word){ // for s in word:
mapa[s] += 1; // {"a": 2, "b": 1, "c": 1}
}
}
bool respuesta = true;
for(auto [k, v] : mapa){ // for k, v in mapa.items():
// cout << k << " " << v << "\n"; // print(k, v)
if (v % n != 0){
respuesta = false;
}
}
cout << (respuesta ? "YES" : "NO") << "\n"; // "YES" if respuesta else "NO"
}
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment