hihoCoder太阁最新面经算法竞赛9 register

Ended

Participants:256

Verdict:Accepted
Score:100 / 100
Submitted:2016-07-24 11:07:38

Lang:G++

Edit
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#include<iostream>
#include<list>
#include<string>
#include<map>
using namespace std;
int main(){
    int n, m;
    string s;
    map<string, int> urlmap;
    list<string> urllist;
    map<string, int>::iterator it;
    cin >> n >> m;
    for (int i = 0; i < n; i++){
        cin >> s;
        it = urlmap.find(s);
        //map
        if (it == urlmap.end()){
            cout << "Internet" << endl;
            //map
            if (urlmap.size() >= m){
                string str = urllist.back();
                urllist.pop_back();
                urlmap.erase(str);
            }
            //map
            urlmap[s] = i;
            urllist.push_front(s);
        }
        //map
        else{
            urllist.remove(s);
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX