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

Ended

Participants:256

Verdict:Time Limit Exceeded
Score:50 / 100
Submitted:2016-07-23 16:08:58

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<algorithm>
#include<iostream>
#include<list>
#include<string>
using namespace std;
int main()
{
    int N,M;
    cin >> N >> M;
    list<string> l;
    list<string>::iterator it;
    string s;
    while(N--)
    {
        s.clear();
        cin >> s;
        it = find(l.begin(),l.end(),s);
        if(it != l.end())
        {
            l.erase(it);
            l.push_back(s);
            cout << "Cache" << endl;
            continue;
        }
        else
        {
            if(l.size() < M)
            {
                l.push_back(s);
            }
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX