题意:

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. 杂题_POJ上的过桥问题

    本文出自:http://blog.csdn.net/svitter 过桥问题解释:一条船能够坐两个人,可是有非常多人要过河,所以送过一个人去,还有一个人还要回来接.使全部人过河之后时间最短,怎样求? ...

  2. C#压缩与解压

    using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.I ...

  3. Qt之多线程

    源地址:http://blog.csdn.net/liuhongwei123888/article/details/6072320 Qt 是一种基于 C++ 的跨平台 GUI 系统,能够提供给用户构造 ...

  4. 一些Windows API导致的Crash以及使用问题总结

    RegQueryValueEx gethostbyname/getaddrinfo _localtime64 FindFirstFile/FindNextFile VerQueryValue Crea ...

  5. SRM 583 Div II Level Three:GameOnABoard,Dijkstra最短路径算法

    题目来源:http://community.topcoder.com/stat?c=problem_statement&pm=12556 用Dijkstra实现,之前用Floyd算法写了一个, ...

  6. Thinkphp入门 五 —模型 (49)

    原文:Thinkphp入门 五 -模型 (49) [数据库操作model模型] model  模型  数据库操作 tp框架主要设计模式:MVC C:controller   控制器   shop/Li ...

  7. javascript中apply和eval结合的强大用法

        eval是一个函数,可以接受一个参数,这个参数可以作为js语句被解释性的执行,利用这个特性,eval和apply结合起来,可以大大简化代码  如下例子 <a class="cl ...

  8. Transformations 方块转换

    题目是中文题,就不做什么解释了,纯模拟题,主要要搞清楚这几种装换方式下标的变化: 第一种:顺时针旋转90度: c[j][n-i+1]=a[i][j]; 第二种:旋转180度: c[n-i+1][n-j ...

  9. 【HTML】让<pre>标签文本自动换行

    利用<pre></pre>这个标签可以将其包起来的文字排版.格式,原封不动的呈现出来. 也就是说你输入的东西被原封不动的输出,包括你输入的空格之类的,不用 和<BR> ...

  10. boost function对象

    本文根据boost的教程整理. 主要介绍boost function对象的用法. boost function boost function是什么 boost function是一组类和模板组合,用于 ...