1496. Spammer
Time limit:1.0 Second
Memory limit:64 MB
There is a famous spammer among our friends. In the end of every contest he was submitting his incorrect solutions at the speed of a machine-gun. In addition, the He cheats by means of the using several accounts for debugging. The judges eventually decided to disqualify the spammer. For this, they first want to discover all of his debugging accounts. The judges know which teams submitted their solutions in the last ten minutes of a contest. They regard as the spammer ' s debugging accounts all accounts which submitted solutions at least twice during the last ten Minutes of the contest. Your task is to find these accounts.InputThe first line contains the number N of submissions in the last ten minutes (0≤n≤100). The next N lines contain the names of teams which submitted their solutions in this period. The names contain only digits and lowercase 中文版 letters. Each name was not longer than symbols.OutputOutput in a arbitrary order all accounts which, in the judges ' opinion, is used by the spammer.Sample
input |
Output |
Naucoder
iceman
Abikbaev
Abikbaev
Petr
Abikbaev
Abikbaev
x
Abikbaev
Acrush
X |
X
Abikbaev
|
Test instructions: The output has a string of not less than two occurrences.
Parse: Map directly to engage.
AC Code:
#include <cstdio>
#include <map>
#include <string>
#include <iostream>
using namespace std;
Map<string, int> A;
int main () {
#ifdef sxk
freopen ("In.txt", "R", stdin);
#endif//sxk
int n;
string S;
while (scanf ("%d", &n) ==1) {while
(n--) {
cin>>s;
A[s] + +;
}
Map<string, int>::iterator it;
for (it = A.begin (); it!=a.end (); it + +) {
if (It->second >= 2) cout<<it->first<<endl;
}
}
return 0;
}