题意:

CLJ找了很多妹子…  (题目好没节操…)  对于CLJ和妹子的聊天对话框  有一下几种操作:

add  加一个妹子在聊天窗队列末尾  假设这个妹子已经在队列中则add失败

close  关掉某个妹子的聊天窗体  假设没有这个妹子的对话框则close失败  假设成功要输出和这个妹子说过几个词

chat  和最前面妹子说一些话  假设没有窗体打开则chat失败

rotate  将某个妹子移到最前面  假设寻找妹子时发现超出队列范围则rotate失败

prior  将优先级最高妹子移到最前面  假设没有对话框则prior失败

choose  选择某个妹子移到最前面  假设该妹子不在队列则choose失败

top  选择某个妹子将她的状态变为总在最前  假设妹子不在队列则top失败  假设以前有总在最前的妹子  则代替之

untop  撤销总在最前状态  假设没人总在最前则untop失败

最后依照队列顺序  与每个以前说过话的妹子道别

思路:

模拟题…  写写写…

总在最前是一种状态  要理解  它并不直接改变队伍形状

即  第三个妹子被top  再被untop  这时这个妹子依旧站在第三个位置上

注意几个坑点:

close时候可能关掉的是总在最前的妹子的对话框  这时总在最前也同一时候消失

chat要用__int64存储每一个妹子对话过几个词

最后道别时候应该先于总在最前的妹子道别

代码:

#include<cstdio>
#include<iostream>
#include<cstring>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<vector>
#include<queue>
#include<cstdlib>
#include<ctime>
#include<cmath>
#include<bitset>
using namespace std;
typedef __int64 LL;
#define M 5010 struct girl {
int prior;
LL word;
} g[M];
int T, n, tot, alwaysontop; int main() {
int i, u, j, success, w, x;
char op[30];
scanf("%d", &T);
while (T--) {
scanf("%d", &n);
tot = 0;
alwaysontop = -1;
for (i = 1; i <= n; i++) {
printf("Operation #%d: ", i);
scanf("%s", op);
if (strcmp(op, "Add") == 0) {
scanf("%d", &u);
success = 1;
for (j = 0; j < tot; j++) {
if (g[j].prior == u) {
success = 0;
break;
}
}
if (success) {
printf("success.\n");
g[tot].prior = u;
g[tot].word = 0;
tot++;
} else
printf("same priority.\n");
} else if (strcmp(op, "Close") == 0) {
scanf("%d", &u);
success = 0;
for (j = 0; j < tot; j++) {
if (g[j].prior == u) {
success = 1;
u = j;
break;
}
}
if (success) {
if (g[u].prior == alwaysontop)
alwaysontop = -1;
printf("close %d with %I64d.\n", g[u].prior, g[u].word);
for (j = u; j < tot; j++)
g[j] = g[j + 1];
tot--;
} else
printf("invalid priority.\n");
} else if (strcmp(op, "Chat") == 0) {
scanf("%d", &w);
if (alwaysontop != -1) {
for (u = 0; u < tot; u++) {
if (g[u].prior == alwaysontop) {
g[u].word += w;
break;
}
}
printf("success.\n");
} else if (tot > 0) {
g[0].word += w;
printf("success.\n");
} else
printf("empty.\n");
} else if (strcmp(op, "Rotate") == 0) {
scanf("%d", &x);
if (x >= 1 && x <= tot) {
x--;
while (x) {
swap(g[x], g[x - 1]);
x--;
}
printf("success.\n");
} else
printf("out of range.\n");
} else if (strcmp(op, "Prior") == 0) {
if (tot) {
u = 0;
for (j = 1; j < tot; j++) {
if (g[j].prior > g[u].prior)
u = j;
}
while (u) {
swap(g[u], g[u - 1]);
u--;
}
printf("success.\n");
} else
printf("empty.\n");
} else if (strcmp(op, "Choose") == 0) {
scanf("%d", &u);
success = 0;
for (j = 0; j < tot; j++) {
if (g[j].prior == u) {
success = 1;
u = j;
break;
}
}
if (success) {
while (u) {
swap(g[u], g[u - 1]);
u--;
}
printf("success.\n");
} else
printf("invalid priority.\n");
} else if (strcmp(op, "Top") == 0) {
scanf("%d", &u);
success = 0;
for (j = 0; j < tot; j++) {
if (g[j].prior == u) {
success = 1;
break;
}
}
if (success) {
alwaysontop = u;
printf("success.\n");
} else
printf("invalid priority.\n");
} else if (strcmp(op, "Untop") == 0) {
if (alwaysontop != -1) {
alwaysontop = -1;
printf("success.\n");
} else
printf("no such person.\n");
}
}
if (alwaysontop != -1) {
for (j = 0; j < tot; j++) {
if (g[j].prior == alwaysontop) {
u = j;
break;
}
}
if (g[u].word)
printf("Bye %d: %I64d\n", g[u].prior, g[u].word);
}
for (j = 0; j < tot; j++) {
if (g[j].word && g[j].prior != alwaysontop) {
printf("Bye %d: %I64d\n", g[j].prior, g[j].word);
}
}
}
return 0;
}

HDU 5071 Chat的更多相关文章

  1. hdu 5071 Chat(模拟)

    题目链接:hdu 5071 Chat 题目大意:模拟题. .. 注意最后说bye的时候仅仅要和讲过话的妹子说再见. 解题思路:用一个map记录每一个等级的妹子讲过多少话以及是否有这个等级的妹子.数组A ...

  2. HDU 5071 Chat(2014鞍山B,模拟)

    http://acm.hdu.edu.cn/showproblem.php?pid=5071 Chat Time Limit: 2000/1000 MS (Java/Others)    Memory ...

  3. HDU 5071 Chat(2014鞍山赛区现场赛B题)

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=5071 解题报告:一个管理聊天窗口的程序,一共有八种操作,然后要注意的就是Top操作只是把编号为u的窗口 ...

  4. hdu 5071 Chat(模拟|Splay)

    Chat Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 262144/262144 K (Java/Others) Total Sub ...

  5. HDU - 5071 Chat(模拟)

    原题链接 题意:有各种操作,模拟这个程序并输出每次操作的信息 分析:恶心模拟题...用个map记录一下各个等级女孩的谈话数,同时也便于查找权值为u的在不在队列里.因为n很小,其他就暴力模拟了. #in ...

  6. hdu 5071 Chat-----2014acm亚洲区域赛鞍山 B题

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=5071 Chat Time Limit: 2000/1000 MS (Java/Others)    M ...

  7. hdu 5071(2014鞍山现场赛B题,大模拟)

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=5071 思路:模拟题,没啥可说的,移动的时候需要注意top的变化. #include <iostr ...

  8. hdu 5071 vector操作恶心模拟

    http://acm.hdu.edu.cn/showproblem.php?pid=5071 对于每一个窗口,有两个属性:优先级+说过的单词数,支持8个操作:新建窗口,关闭窗口并输出信息,聊天(置顶窗 ...

  9. HDOJ 5071 Chat 模拟

    大模拟: 1>saygoodbye要先对 always on top 的人说 2>对没有说过话的不要说good bye 3>用long long Chat Time Limit: 2 ...

随机推荐

  1. Windows Azure 安全最佳实践 - 第 3 部分:确定安全框架

    构建云应用程序时,安全始终是计划和执行Windows Azure的首要核心因素.第 1 部分提出安全是一项共同责任,Windows Azure为您的应用程序提供超出内部部署应用程序需求的强大安全功能. ...

  2. 【thinking in java】读书笔记(一)

    近期開始读tij,好记性不如烂笔头,所以还是记录一下,方便以后查阅. 一.各种初始化问题: 方法重载的问题: 方法的重载,差别是靠传入方法的參数,而不是返回值.比方f(),假设是返回值的话,easy产 ...

  3. TEXT文本编辑框4 点击按钮读取文本框内容到内表

    *&---------------------------------------------------------------------* *& Report ZTEST_CWB ...

  4. treeview树形菜单,递归

    我使用的是递归是实现无限级树形菜单: using System; using System.Collections; using System.Configuration; using System. ...

  5. 2015 Multi-University Training Contest 1

    最近真是太废柴了,题没做几道,也没学什么新知识,多校做了三场也没总结~诶!好好学吧! 多校第一场感觉被完虐...orz... Hdu 5288 OO’s Sequence 题目链接:http://ac ...

  6. iebook 发布到网站 独家秘诀

    iebook 普通版只能产生exe文件,无法生成web公布的文件需要,因此,我们需要专业版. iebook2011版本并没有破解版,下面是一个iebook2010破解版: http://downloa ...

  7. CPU 球迷助威清理灰尘图形的全过程

    主机因为使用时间长的电源风扇,风扇轴承石油枯竭,导致拒绝或不转的风扇转速,热量使电源不能得到有效排除,往往会造成电脑死机,有几种方法来解决. 单省钱的办法例如以下: 1.把电源从主机上拆下,例如以下图 ...

  8. ALV双击单元格事件处理

    *激发双击事件 FORM f_alv_user_command USING r_ucomm LIKE sy-ucomm rs_selfield TYPE slis_selfield. "先引 ...

  9. ABAP函数:VIEW_MAINTENANCE_CALL(维护表视图等)

    function:VIEW_MAINTENANCE_CALL 功能:维护表视图等 The function module calls the extended table maintenance (V ...

  10. cct软件测试

    <全国计算机等级考试三级教程:软件测试技术(2016年版)>根据教育部考试中心制订的<全国计算机等级考试三级软件测试技术考试大纲(2013年版)>编写而成.主要内容包括软件测试 ...