- 自分の使っているtopcoderヘルプツールで自動生成されるコードでは、実装対象のクラスオブジェクトがmainの自動変数として宣言されていることに気付かずちょっとはまった。
#include <sstream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <iostream>
#include <utility>
#include <set>
#include <cctype>
#include <queue>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cmath>
using namespace std;
class InterestingParty{
public:
int bestInvitation(vector <string> first, vector <string> second){
map<string, int> interest;
for(int i = 0; i < (int)first.size(); i++){
map<string, int>::iterator it;
it = interest.find(first[i]);
if(it == interest.end()){
interest[first[i]] = 1;
}
else{
interest[first[i]] += 1;
}
it = interest.find(second[i]);
if(it == interest.end()){
interest[second[i]] = 1;
}
else{
interest[second[i]] += 1;
}
}
{
for(map<string, int>::iterator it = interest.begin(); it != interest.end(); it++){
cout << it->first << "\t" << it->second << endl;
}
}
int ret = 0;
for(map<string, int>::iterator it = interest.begin(); it != interest.end(); it++){
ret = max(it->second, ret);
}
return ret;
}
};