【hihocoder】Browser Cache
来源:互联网 发布:淘宝超出七天退换货 编辑:程序博客网 时间:2024/06/10 20:24
本题根据hihocoder oj提供的解题报告编写:
http://hihocoder.com/discuss/question/2154
/** * @author johnsondu * @createTime 2015.09.06 15:59 * @problem hihocoder: Browser Caching * @url http://hihocoder.com/contest/hiho62/problem/1 * @type simple simulation of LRU cache */#include <iostream>#include <cstdio>#include <cmath>#include <algorithm>#include <string>#include <queue>#include <stack>#include <map>using namespace std;const int N = 20005;int n, m;map<string, int> lastVisit;string a[N];int main(){ scanf("%d%d", &n, &m); int cacheCnt = 0; int start = 1; for(int i = 1; i <= n ; i ++) { cin >> a[i]; if(lastVisit[a[i]] >= start && lastVisit[a[i]] <= i) printf("Cache\n"); else { printf("Internet\n"); cacheCnt ++; // 缓存已满 if(cacheCnt > m) { start = start + 1; } } //更新最后一次访问时间 lastVisit[a[i]] = i; //更新s找到最新的最早的访问记录 while(lastVisit[a[start]] != start) start = start + 1; } return 0;}
0 0
- 【hihocoder】Browser Cache
- Hihocoder 1086 Browser Caching
- Cleaning browser cache
- Browser side cache tips
- hihocoder Browser Caching(字符串hash)
- 【hihoCoder】#1086: Browser Caching (微软笔试题)
- How To Clear A Browser Cache
- browser
- browser
- Browser
- browser
- [hihoCoder太阁最新面经算法竞赛9] 题目一:Browser Caching (LRU缓存)
- hihocoder:
- hihoCoder
- Hihocoder
- hihocoder
- hihocoder
- hihocoder
- Redis集群配置
- Jsoup 学习笔记
- asp.net 点击完按钮后刷新页面发现还会触发buttonClick事件
- log4j生成日志文件
- sass语法整理
- 【hihocoder】Browser Cache
- inputView与inputAccessoryView
- 从github源码安装elixir
- Android官方侧滑DrawerLayout用法
- notepad++使用正则进行替换
- jQuery(8) 实现Ajax应用
- 7.1.4构造函数
- MySQL学习----MySQL数据类型----01MySQL 数值类型
- 丁海森: 域名投资无须营业执照,小生意,大买卖?