int main() { # ifdef _DEBUG freopen("i.in", "r", stdin); # else freopen("i.in", "r", stdin); freopen("i.out", "w", stdout); # endif ios_base::sync_with_stdio(false); cin.tie(NULL); words.reserve(20000); int i; string s; while (cin >> s) { if (s == "<text>") { q.push((lastMap = new Memory)); if (q.size() > 7) { Memory* toDel = q.front(); for (i = 0; i < (int)words.size(); i++) sevenDaysMap.words[i].count -= toDel->words[i].count; q.pop(); } while (cin >> s, s != "</text>") { if (s.length() < 4) continue; map<string, int>::iterator lb = wordMap.lower_bound(s); int id; if (lb != wordMap.end() && !wordMap.key_comp()(s, lb->first)) { //existing. id = lb->second; } else { //new. id = words.size(); wordMap.insert(lb, make_pair(s, id)); words.push_back(s); } lastMap->words[id].count++; sevenDaysMap.words[id].count++; } } else if (s == "<top") {
C get_comparator() { return weak_refs.key_comp(); }