hdu 1972
来源:互联网 发布:邓肯巅峰数据 编辑:程序博客网 时间:2024/05/16 17:15
这题太水了,一个暴力模拟就A了。
排队时,若是权值递增,那么最坏的情况是n!。可拍,可是n最大100。
/**TASK: crypt1LANG: C++ID: DickensTone**/#include<cstdio>#include<cstring>#include<fstream>#include<iostream>#include<queue>#include<algorithm>using namespace std;const int maxn = 100 + 5;struct node{ int id; int val; node(int x, int y):id(x), val(y){}};bool cmp(int x, int y){ return x > y;}int num[maxn];int main(){ //freopen("crypt1.in", "r", stdin); //freopen("crypt1.out", "w", stdout); int m, n, T; queue<node> q; scanf("%d", &T); while(T--) { memset(num, 0, sizeof(num)); while(!q.empty()) q.pop(); int m, n; scanf("%d%d", &m, &n); for(int i = 0; i < m; i++) { int t; scanf("%d", &t); num[i] = t; q.push(node(i, t)); } sort(num, num + m, cmp); int ans = 0, cnt = 0; while(!q.empty()) { node temp = q.front(); q.pop(); if(num[cnt] != temp.val) q.push(temp); else { cnt++; ans++; if(temp.id == n) break; } } printf("%d\n", ans); } return 0;}
阅读全文
0 0
- hdu 1972
- hdu 1972 队列模拟
- hdu
- hdu
- HDU
- hdu ()
- hdu
- hdu
- HDU
- HDU
- hdu
- hdu
- HDU
- Hdu
- hdu
- hdu-
- hdu
- hdu
- 初始测试博客
- Java学习笔记之JDK1.5新特性(三):可变参数
- 批处理bat万能删除文件/夹
- 2017第二届互联网+研修班即将于10月召开啦!
- 数据结构实验之串三:KMP应用 简单应用
- hdu 1972
- 项目中sql insert语句一定要规范写
- 谈谈url重写
- 利用IPMI挂载镜像装系统
- 第二章、SQLServer 工具
- XlsxWriter模块常用方法说明
- Java学习笔记之JDK1.5新特性(四):自动装箱和自动拆箱
- OpenStack Tacker介绍
- 一分钟解决你的公有云私有云选择困难症