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

Ended

Participants:256

Verdict:Wrong Answer
Score:30 / 100
Submitted:2016-07-22 11:39:01

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
#include <iostream>
#include <set>
#include <queue>
#include <cstring>
using namespace std;
int main(){
    int N, M;
    cin >> N >> M;
    set<string> myset;
    queue<string> myqueue;
    for(int i=0; i<N; i++){
        string str;
        cin >> str;
        if(myset.find(str) == myset.end()){
            cout << "Internet" << endl;
            myqueue.push(str);
            myset.insert(str);
            if(myqueue.size() > M){
                string top = myqueue.front();
                myqueue.pop();
                myset.erase(top);
            }
        }
        else{
            cout << "Cache" << endl;
        }
    }
}
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX