原题链接

题意:有各种操作,模拟这个程序并输出每次操作的信息

分析:恶心模拟题。。。用个map记录一下各个等级女孩的谈话数,同时也便于查找权值为u的在不在队列里。因为n很小,其他就暴力模拟了。

#include <iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<map>
#define ll long long
#define ull unsigned long long
//#define LOCAL using namespace std;
const int maxn=+;
const int inf=0x3f3f3f3f;
const int mod=1e9+; map<int,ll> C;
//flag标记always on top,T为其优先值
int x,T,A[maxn],N,flag; int find(int a){
for(int i=;i<N;i++)
if(A[i]==a)
return i;
return N;
}
void add(){
scanf("%d",&x);
if(C.count(x)) printf("same priority");
else{
A[N++]=x;
C[x]=;
printf("success");
}
}
void close(){
scanf("%d",&x);
if(C.count(x)){
printf("close %d with %I64d",x,C[x]);
C.erase(x);
if(flag&&T==x) flag=;
int pos=find(x);
for(int i=pos;i<N;i++) A[i]=A[i+];
N--;
}
else printf("invalid priority");
}
void chat(){
scanf("%d",&x);
if(N==) printf("empty");
else{
if(flag) C[T]+=x;
else C[A[]]+=x;
printf("success");
}
}
void roate(){
scanf("%d",&x);
if(x>N||x<) printf("out of range");
else{
int t=A[x-];
for(int i=x-;i;i--) A[i]=A[i-];
A[]=t;
printf("success");
}
}
void prior(){
if(N==) printf("empty");
else{
int pos=,maxx=A[];
for(int i=; i<N; i++){
if(A[i]>maxx){
maxx=A[i];
pos=i;
}
}
int t=A[pos];
for(int i=pos;i;i--) A[i]=A[i-];
A[]=t;
printf("success");
}
}
void choose(){
scanf("%d",&x);
if(C.count(x)){
int pos=find(x);
int t=A[pos];
for(int i=pos;i;i--) A[i]=A[i-];
A[]=t;
printf("success");
}
else printf("invalid priority");
}
void top1(){
scanf("%d",&x);
if(C.count(x)){
T=x;
flag=;
printf("success");
}
else printf("invalid priority");
}
void untop(){
if(flag){
flag=;
printf("success");
}
else printf("no such person");
}
void bye(){
if(N==) return;
if(flag&& C[T]) printf("Bye %d: %I64d\n",T,C[T]);
for(int i=;i<N;i++){
if(flag&& A[i]==T) continue;
if(C[A[i]]) printf("Bye %d: %I64d\n",A[i],C[A[i]]);
}
} int main(){
//ios::sync_with_stdio(false);
#ifdef LOCAL
freopen("in.txt","r",stdin);
#endif
int t,n;
cin>>t;
while(t--)
{
N=T=flag=;
C.clear();
scanf("%d",&n);
char s[];
for(int i=; i<=n; i++){
scanf("%s",s);
printf("Operation #%d: ",i);
if(strcmp(s,"Add")==) add();
else if(strcmp(s,"Chat")==) chat();
else if(strcmp(s,"Close")==) close();
else if(strcmp(s,"Rotate")==) roate();
else if(strcmp(s,"Prior")==) prior();
else if(strcmp(s,"Choose")==) choose();
else if(strcmp(s,"Top")==) top1();
else if(strcmp(s,"Untop")==) untop();
printf(".\n");
}
bye();
}
return ;
}

HDU - 5071 Chat(模拟)的更多相关文章

  1. hdu 5071 Chat(模拟)

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

  2. hdu 5071 Chat(模拟|Splay)

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

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

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

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

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

  5. HDOJ 5071 Chat 模拟

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

  6. HDU 5071 Chat

    题意: CLJ找了很多妹子-  (题目好没节操-)  对于CLJ和妹子的聊天对话框  有一下几种操作: add  加一个妹子在聊天窗队列末尾  假设这个妹子已经在队列中则add失败 close  关掉 ...

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

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

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

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

  9. hdu 5071 vector操作恶心模拟

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

随机推荐

  1. 基于FPGA的数字秒表(数码管显示模块和按键消抖)实现

    本文主要是学习按键消抖和数码管动态显示,秒表显示什么的,个人认为,拿FPGA做秒表真是嫌钱多. 感谢 感谢学校和至芯科技,笔者专业最近去北京至芯科技培训交流了一周.老师的经验还是可以的,优化了自己的代 ...

  2. Awesome-3d

    1.素描-你的3D内容在网络,移动,AR,和虚拟现实. 2.跨平台AR SDK =======================

  3. 可前端解密的加密方法探讨和str_replace和preg_replace分析

    目的: 对字符串‘123456’进行后端加密,前端js可解密出真实字符 测试代码php: static $hashMap = array( '0' => '4', '1' => '9', ...

  4. docker_macvlan

    目录 macvlan macvlan macvlan的原理是在宿主机物理网卡上虚拟出多个子网卡,通过不同的MAC地址在数据链路层(Data Link Layer)进行网络数据转发的,它是比较新的网络虚 ...

  5. 使用BlockQueue实现生产者和消费者模式

    数据 package cn.lonecloud.procum; /** * @author lonecloud * @version v1.0 * @date 上午11:00 2018/5/7 */ ...

  6. linux ./configure check your system clock

    checking for a BSD-compatible install... /usr/bin/install -cchecking whether build environment is sa ...

  7. Surface Pro 4 系统优化全教程及QA

    甲.如何根据你的需求选择相应版本的surface1.Core M3-6Y30,Core i5-6300U,Core i7-6650U的性能差距有多大?2.HD 515,HD520,Iris 540的性 ...

  8. ftp sun jdk自带

    package com.italktv.colnv.stat.util; import java.io.File; import java.io.FileInputStream; import jav ...

  9. electron入门笔记(三)- 引入bootstrap

    源码:https://github.com/sueRimn/electron-bootstrap 当引入jQuery和bootstrap文件时,会报错,原因是:electron 的 Renderer ...

  10. 洛谷P2486 染色

    LCT的一种姿势. 题意:给定一棵树.每次把一条路径上的点染成一种颜色,求一条路径上有多少段颜色. 解: 首先可以很轻易的用树剖解决,只不过代码量让人望而却步... 有一种难以想象的LCT做法... ...