hdu 5017
好恶心的题
#include <cstdio>
#include <string.h>
#include <algorithm>
#include <cmath>
#include <set>
using namespace std;
typedef __int64 ll;
struct point{
ll word,priori;
}P[];
char T[][]={ {"Add"},{"Close"},{"Chat"},{"Rotate"},{"Prior"},{"Choose"},{"Top"},{"Untop"}};
int sz,op,always=-;
void per(int x){
point ttt = P[x];
for(int i=x; i>; --i)
P[i]=P[i-];
P[]=ttt;
}
void last(int x){
point ttt= P[x];
for(int i=x; i<sz-; ++i)
P[i]=P[i+];
P[sz-]=ttt;
}
void solve0(){
ll id;
scanf("%I64d",&id);
int loc=-;
for(int i=; i<sz; ++i)
if( P[i].priori == id ){
loc=i; break;
}
if( loc == - ){
P[sz].word=;
P[sz].priori=id;
sz++;
printf("Operation #%d: success.\n",op++);
}else{
printf("Operation #%d: same priority.\n",op++);
}
}
void solve1(){
ll id;
scanf("%I64d",&id);
int loc=-;
for(int i=; i<sz; ++i)
if(P[i].priori==id){
loc=i; break;
}
if(loc==-){
printf("Operation #%d: invalid priority.\n",op++);
}else {
printf("Operation #%d: close %I64d with %I64d.\n",op++,P[loc].priori,P[loc].word);
if(P[loc].priori==always) always=-;
for(int i=loc+; i<sz; ++i)
P[i-]=P[i];
sz--;
}
}
void solve2(){
ll id;
scanf("%I64d",&id);
if(sz==){ ///*****************************
printf("Operation #%d: empty.\n",op++);
}else{
if(always!=-){
for(int i=; i<sz; ++i)
if(P[i].priori==always){
P[i].word+=id; break;
}
}else P[].word+= id;
printf("Operation #%d: success.\n",op++);
}
}
void solve3(){
ll id;
scanf("%I64d",&id);
id--;
if( id< || id >= sz){
printf("Operation #%d: out of range.\n",op++);
}else{
point ttt=P[id];
for(int i=id; i>; --i)
P[i]=P[i-];
P[]=ttt;
printf("Operation #%d: success.\n",op++);
}
}
void solve4(){
if(sz==){
printf("Operation #%d: empty.\n",op++);
}else{
int loc=;
ll hi=-;
for(int i=; i<sz; ++i)
if(P[i].priori>hi) hi=P[i].priori,loc=i;
point ttt=P[loc];
for(int i=loc; i>; --i)
P[i]=P[i-];
P[]=ttt;
printf("Operation #%d: success.\n",op++);
}
}
void solve5(){
ll id;
scanf("%I64d",&id);
int loc=-;
for(int i=; i<sz; ++i)
if(P[i].priori==id){
loc=i; break;
}
if(loc==-){
printf("Operation #%d: invalid priority.\n",op++); return;
}
point ttt=P[ loc ];
for(int i=loc; i>; --i)
P[i]=P[i-];
P[]=ttt;
printf("Operation #%d: success.\n",op++);
}
void solve6(){
ll id;
scanf("%I64d",&id);
int loc=-;
for(int i=; i<sz; ++i)
if(P[i].priori==id){
loc=i; break;
}
if(loc==-){
printf("Operation #%d: invalid priority.\n",op++); return;
}
always=id;
printf("Operation #%d: success.\n",op++);
}
void solve7(){
if(always==-){
printf("Operation #%d: no such person.\n",op++); return;
}
always=-;
printf("Operation #%d: success.\n",op++);
}
int main(){ int cas;
scanf("%d",&cas);
char str[];
for(int cc= ; cc<=cas; ++cc){
int n;
scanf("%d",&n);
always=-;
sz=;op=;
for(int i=; i<n; ++i){
scanf("%s",str);
if(strcmp(str,T[])==) solve0();
else if(strcmp(str,T[])==) solve1();
else if(strcmp(str,T[])==) solve2();
else if(strcmp(str,T[])==) solve3();
else if(strcmp(str,T[])==) solve4();
else if(strcmp(str,T[])==) solve5();
else if(strcmp(str,T[])==) solve6();
else if(strcmp(str,T[])==) solve7();
// printf(".\n");
}
if(always!=-){
for(int i=; i<sz; ++i)
if(P[i].priori==always&&P[i].word!=){
printf("Bye %I64d: %I64d\n",P[i].priori,P[i].word); break;
}
}
for(int i=; i<sz; ++i)
if(P[i].priori!=always&&P[i].word!=){
printf("Bye %I64d: %I64d\n",P[i].priori,P[i].word);
} }
return ;
}
hdu 5017的更多相关文章
- hdu 5017 模拟退火算法
hdu 5017 http://blog.csdn.net/mypsq/article/details/39340601 #include <cstdio> #include <cs ...
- hdu 5017 模拟退火/三分求椭圆上离圆心最近的点的距离
http://acm.hdu.edu.cn/showproblem.php?pid=5017 求椭圆上离圆心最近的点的距离. 模拟退火和三分套三分都能解决 #include <cstdio> ...
- hdu 5017 模拟退火
题意:给出椭球面的立体解析式,要求椭球面上距离原点最近的点的距离 sol:这题要想推公式就
- HDU 5017 Ellipsoid 模拟退火第一题
为了补这题,特意学了下模拟退火算法,感觉算法本身不是很难,就是可能降温系数,步长等参数不好设置. 具体学习可以参见: http://www.cnblogs.com/heaad/archive/2010 ...
- 2014 ACM/ICPC Asia Regional Xi'an Online(HDU 5007 ~ HDU 5017)
题目链接 A题:(字符串查找,水题) 题意 :输入字符串,如果字符串中包含“ Apple”, “iPhone”, “iPod”, “iPad” 就输出 “MAI MAI MAI!”,如果出现 “Son ...
- hdu 5017 Ellipsoid(西安网络赛 1011)
Ellipsoid Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others) Total ...
- HDU - 5017 Ellipsoid(模拟退火法)
Problem Description Given a 3-dimension ellipsoid(椭球面) your task is to find the minimal distance bet ...
- HDU - 5017 Ellipsoid(模拟退火)
题意 给一个三维椭球面,求球面上距离原点最近的点.输出这个距离. 题解 模拟退火. 把\(z = f(x, y)\)函数写出来,这样通过随机抖动\(x\)和\(y\)坐标就能求出\(z\). 代码 / ...
- NOIp2018停课刷题记录
Preface 老叶说了高中停课但是初中不停的消息后我就为争取民主献出一份力量 其实就是和老师申请了下让我们HW的三个人听课结果真停了 那么还是珍惜这次机会好好提升下自己吧不然就\(AFO\)了 Li ...
随机推荐
- python2.0 s12 day8 _ socketserver学习
Socket 概念 一个socket就是一个点对点的链接.当今,大多数的通信都是基于Internet Protocl,因此大多数的网络Socket都是Internet Protocl(互联网)的通信( ...
- OSG绘制金字塔geode+动态纹理坐标
osg::Node* createPyramidModel() { // create the root node which will hold the model. osg::Group* roo ...
- AFNetworking 上传文件
本文转载至 http://blog.csdn.net/hmt20130412/article/details/36487055 文件上传AFNetworking @第一种:我的 #pragma mar ...
- Golang文件名命名规则
在golang源代码中,经常看到各种文件名,比如: bolt_windows.go. 下面对文件名命令规则的说明: 1.平台区分 文件名_平台. 例: file_windows.go, file_un ...
- mysql如何查询日期的列表?
转自:http://blog.csdn.net/liufei198613/article/details/72643345 select @num:=@num+1,date_format(adddat ...
- 无法远程访问Mysql
1.故障状态 [root@server02 ~]# mysql -utuser -h192. -p Enter password: ERROR (HY000): Can't connect to My ...
- 【css预处理器】------css预处理器及sass基本介绍------【巷子】
001.什么是css预处理器? css预处理器定义了一种新的语言.用一种专门的编程语言,为css增加了一些编程的特性,将css作为目标生成文件,然后开发者就只要使用这种语言进行编码工作.(通俗点说“” ...
- 新增form表单,post提交.2
- Pentaho Report Designer 数据大于某值显示红色
在细节栏中的字段的属性, 在样式的text-color,右边的表达式 输入下面表达式即可! =IF( [ALL_VALUE] > 50 ; "black" ; IF([ALL ...
- New动态分配 Delete 释放内存
在C++中,对于变量和对象都是编译器在编译时分配好的,对于数组初始化时,无法确定多少内存,很容意造成大开小用的情况. new 动态分配 一般格式:1. 指针变量名 =new 类型标识符; 2.指针 ...