hiho week 62 register

Ended

Participants:714

Verdict:Accepted
Score:100 / 100
Submitted:2015-09-06 13:40:36

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<map>
#include<string>
#include<iostream>
using namespace std;
const int MaxN=20001;
const int MaxM=5001;
map<string,int> lv;
string url[MaxN];
int N,M,s,t,i;
int main()
{
    lv.clear();
    scanf("%d%d\n",&N,&M);
    for(i=0;i<N;++i)
    {
        cin>>url[i];
        t=i;
        if(lv.count(url[i]))
            cout<<"Cache"<<endl;
        else
        {
            cout<<"Internet"<<endl;
            if(lv.size()==M)
                lv.erase(url[s++]);
        }
        lv[url[i]]=i;
        while(lv[url[s]]!=s)
            ++s;
    }
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX