알고리즘
백준 2607번 비슷한 단어 C++
영춘권의달인
2022. 9. 7. 10:02
#include <iostream>
#include <string>
#include <vector>
#include <math.h>
#include <algorithm>
#include <utility>
#include <stack>
#include <queue>
#include <math.h>
#include <set>
#include <map>
#include <list>
#include <unordered_map>
#include <unordered_set>
#include <iomanip>
#include <limits.h>
#include <bitset>
using namespace std;
using int64 = long long;
int n;
map<char, int> mp;
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
cin >> n;
string str;
cin >> str;
int len = str.length();
for (int i = 0; i < len; i++) {
mp[str[i]]++;
}
int ans = 0;
for (int i = 0; i < n - 1; i++) {
cin >> str;
int wrongCnt = 0;
map<char, int> tmpMp;
for (auto a : mp) {
tmpMp.insert({ a.first,a.second });
}
for (int j = 0; j < str.length(); j++) {
tmpMp[str[j]]--;
}
for (auto a : tmpMp) {
wrongCnt += abs(a.second);
}
if (str.length() == len) {
if (wrongCnt <= 2) ans++;
}
else {
if (wrongCnt <= 1) ans++;
}
}
cout << ans;
}