题意:

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. ASP.NET、WinForm、C# - 配置文件信息读取 [ Web.config || Appconfig ]

    <configuration> <appSettings> <add key="name" value="HF_Ultrastrong&qu ...

  2. QNX简介<转载>

     QNX QNX是由QNX软件系统有限公司开发的实时操作系统. http://blog.csdn.net/happyhell/article/details/7087199 基本特征 * QNX是一个 ...

  3. UVA 2039 Pets(网络流)

    Problem Description Are you interested in pets? There is a very famous pets shop in the center of th ...

  4. XML文件解析之--DOM与SAX

    xml文件又称‘可扩展性标记语言’,可以对文档和数据进行结构化处理,从而能够在部门.客户和供应商之间进行交换,实现动态内容生成,企业集成和应用开发. 我们在进行web开发的时候离不开xml文件,xml ...

  5. PHP学习之-正则表达式

    PHP学习之-正则表达式 1.什么是正则表达式 正则表达式是对字符串处理额一种逻辑公式,就是用特定的字符串组合成一个规则的字符串,称之为正则匹配模式 $p = '/apple/'; $str = '' ...

  6. 基于visual Studio2013解决面试题之0702输出数字

     题目

  7. SQL_查找用户的表属于哪个表空间

    ***********************************************声明*************************************************** ...

  8. hbase memstorelab

    关于MemStore的补充 在通过HStore.add向store中加入�一个kv时,首先把数据写入到memstore中.这一点没有什么说明: publiclongadd(finalKeyValue ...

  9. Swift - 使用Auto Layout和Size Classes实现页面自适应弹性布局

    在过去只有iphone4的时候,可以在代码里将一个可视单元的位置写死,这样是没问题的,但随着iPhone5,6的发布,屏幕尺寸有了越来越多种可能.这就要求App的UI控件具有在不同屏幕尺寸的设备上具有 ...

  10. Delphi线程池

    unit uThreadPool; {   aPool.AddRequest(TMyRequest.Create(RequestParam1, RequestParam2, ...)); } inte ...