Untitled
unknown
plain_text
2 years ago
891 B
5
Indexable
#include <bits/stdc++.h> using namespace std; int c, n, ans1, ans2; string virus, str, ans_str; map <string, int> fMap; int main() { ifstream fin("virus.in"); ofstream fout("virus.out"); fin >> c; fin >> virus; fin >> n; while(n--){ fin >> str; if(str.size() != virus.size()) continue; int cnt = 0; for(int i = 0; i < str.size(); i++) if(str[i] != virus[i]) cnt++; if(cnt != 1) continue; ans1++; fMap[str]++; if(ans2 < fMap[str]) ans_str = str, ans2 = fMap[str]; else if(ans2 == fMap[str]) { if(ans_str.size() == 0) ans_str = str; ans_str = min(ans_str, str); } } if(c == 1) fout << ans1; else fout << ans_str; return 0; }
Editor is loading...