HDU 3031 ToBe Or Not To Be(模拟)
题意:
给你一堆牌,再给你5种操作牌,两个人轮流抓操作牌,并且按照操作来执行,最后谁手里的牌多谁就赢。
明明是左偏树的题目,但是我用priority_queue水过去了。。。
代码:
#include <queue>
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <iostream>#define N 200 + 5using namespace std;typedef struct
{int num ,v;double x ,y ,z;
}NODE;typedef struct
{double dis;int v ,id;
}ZT;NODE node1[N] ,node2[N];
ZT zt[N];
int map[N][N] ,G_b[N][N];
int nowb[N] ,nowg[N];
int mark[N][N];bool camp(ZT a ,ZT b)
{return a.dis < b.dis || a.dis == b.dis && a.v > b.v;
}void Marr(int n)
{queue<int>q;for(int i = 1 ;i <= n ;i ++)q.push(i);memset(mark ,0 ,sizeof(mark));memset(nowb ,255 ,sizeof(nowb));memset(nowg ,255 ,sizeof(nowg));while(!q.empty()){int xin ,tou = q.front();q.pop();for(int i = 1 ;i <= n ;i ++){xin = map[tou][i];if(mark[tou][xin]) continue;mark[tou][xin] = 1;if(nowg[xin] == -1){nowg[xin] = tou;nowb[tou] = xin;break;}else{if(G_b[xin][tou] > G_b[xin][nowg[xin]]){q.push(nowg[xin]);nowg[xin] = tou;nowb[tou] = xin;break;}}}}return;
}double get_dis(NODE a ,NODE b)
{double xx = (a.x - b.x) * (a.x - b.x);double yy = (a.y - b.y) * (a.y - b.y);double zz = (a.z - b.z) * (a.z - b.z);return xx + yy + zz;
}int main ()
{
#ifdef LOCALfreopen("C:\\Users\\john\\Desktop\\in.txt","r",stdin);// freopen("C:\\Users\\john\\Desktop\\out.txt","w",stdout);
#endifint t ,n ,i ,j;scanf("%d" ,&t);while(t--){scanf("%d" ,&n);for(i = 1 ;i <= n ;i ++)scanf("%d %d %lf %lf %lf" ,&node1[i].num ,&node1[i].v ,&node1[i].x ,&node1[i].y ,&node1[i].z);for(i = 1 ;i <= n ;i ++)scanf("%d %d %lf %lf %lf" ,&node2[i].num ,&node2[i].v ,&node2[i].x ,&node2[i].y ,&node2[i].z);for(i = 1 ;i <= n ;i ++){for(j = 1 ;j <= n ;j ++){zt[j].dis = get_dis(node1[i] ,node2[j]);zt[j].v = node2[j].v;zt[j].id = j;// cout << zt[j].dis << endl;}sort(zt + 1 ,zt + n + 1 ,camp);for(j = 1 ;j <= n ;j ++)map[i][j] = zt[j].id;}// for (int i=1;i <= n; i++) {// for (int j = 1; j <= n; j++) cout << map[i][j] << ' ';// cout << endl;// }for(i = 1 ;i <= n ;i ++){for(j = 1 ;j <= n ;j ++){zt[j].dis = get_dis(node2[i] ,node1[j]);// cout << node1[j].num << ' ' << node1[j].v << ' ' << node1[j].x << ' ' << node1[j].y << ' ' << node1[j].z << endl;// cout << zt[j].dis << endl;zt[j].v = node1[j].v;zt[j].id = j;}sort(zt + 1 ,zt + n + 1 ,camp);for(j = 1 ;j <= n ;j ++)G_b[i][zt[j].id] = n - j + 1;}// for (int i = 1; i <= n; i++) {// for (int j = 1; j <= n; j++) cout << G_b[i][j] << ' ' ;// cout << endl;// }Marr(n);for(i = 1 ;i <= n ;i ++)printf("%d %d\n" ,node1[i].num ,node2[nowb[i]].num);puts("");}return 0;
}
HDU 3031 ToBe Or Not To Be(模拟)相关推荐
- hdu 2629 Identity Card (字符串解析模拟题)
这题是一个字符串模拟水题,给12级学弟学妹们找找自信的,嘿嘿; 题目意思就是要你讲身份证的上的省份和生日解析出来输出就可以了: http://acm.hdu.edu.cn/showproblem.ph ...
- 【HDU】4706 Children's Day(模拟)
http://acm.hdu.edu.cn/showproblem.php?pid=4706 该题没有输入,直接输出不同形状大小的N,在输出不同形状N的时候是要用到26个字母,并且是循环输出 #inc ...
- HDU Problem - 6396 Swordsman(优先队列,模拟)
题目链接 Problem Description Lawson is a magic swordsman with kkk kinds of magic attributes v1,v2,v3,-,v ...
- HDU多校5 - 6816 Boring Game(模拟)
题目链接:点击查看 题目大意:给出 n 张叠在一起的纸,现在将其连续从左向右折叠 k 次,再从上到下标上序号,问展开后的序号是怎么样的 题目分析:比赛时一直在找规律,确实是有规律,但是我找不到..去请 ...
- HDU - 1547 Bubble Shooter(dfs+连通块+模拟)
题目链接:点击查看 题目大意:模拟泡泡枪游戏,问当击破指定位置的泡泡时,能有多少个泡泡同时爆炸? 题目分析:一个中规中矩的连通块问题,只不过在向四周扩散的时候需要注意的是,奇数行和偶数行的方向有点不一 ...
- HDU 4740 The Donkey of Gui Zhou (模拟)
由于一开始考虑的很不周到,找到很多bug.....越改越长,不忍直视. 不是写模拟的料...................... 反正撞墙或者碰到已经走过的点就会转向,转向后还碰到这两种情况就会傻站 ...
- HDU 4884 —— TIANKENG’s rice shop(模拟)
题目:TIANKENG's rice shop 题意,就是有N种炒饭,每次炒的时间是t分钟,每次最多炒k份,然后按照进店的顺序给出m个顾客的信息,进店时间,炒饭的编号以及份数.然后要输出每个顾客离开的 ...
- 【HDU - 1013 】Digital Roots (大数模拟)
题干: The digital root of a positive integer is found by summing the digits of the integer. If the res ...
- 【HDU - 1237】简单计算器 (栈模拟)
题干: 读入一个只包含 +, -, *, / 的非负整数计算表达式,计算该表达式的值. Input 测试输入包含若干测试用例,每个测试用例占一行,每行不超过200个字符,整数和运算符之间用一个空格分隔 ...
最新文章
- linux基本知识点学习
- 鸟哥的Linux私房菜(基础篇)- 附录 A: GNU 的 GPL 条文 version 2
- Serverless 解惑——函数计算如何访问 PostgreSQL 数据库
- String对象中常用的方法
- 【专题介绍】用户网络模型与QoE
- vue加百度统计代码(亲测有效)
- Python中Dict的查找
- FreeSql (三十三)CodeFirst 类型映射
- vue-i18n使用及踩坑记录
- 警示!国基金评审过程“打招呼”被通报批评,撤销已资助项目!
- 计算机系统操作工 初级,计算机系统操作工国家职业标准
- word-break: break-all与word-wrap:break-word的区别
- 计算机二级知识汇总手抄报,计算机二级vb_全国计算机二级vb真题
- 菜鸟网管的入门之路-第一章、网络及硬件篇(1)
- 螺旋传动设计系统lisp_螺旋传动设计.doc
- 泛型相关用法(day3)
- joda-time使用方法
- lua—C/C++lua嵌入式开发
- 【报告分享】2021中国锂电行业发展-德勤(附下载)
- JAVA--状态模式
热门文章
- java黑皮书25.18-19----(压缩与解压),带界面,概念版
- 吉林建筑大学电气与计算机学院讲师,吉林建筑大学导师教师信息介绍-电气与计算机学院刘航...
- 睡眠的一场革命!-读《睡眠革命》笔记(中)
- 主题:风电-光热-CHP联合发电系统优化调度
- 大师们怎么养家糊口过日子
- 直播程序源码功能技术详解
- 运用PowerDesigner的反向工程,可以导入SQL脚本,从而生成物理模型
- python春节集五福_2017支付宝集五福 2017年支付宝五福活动的python生福脚本
- MATLAB批量处理.nii文件----批量.nii转为jpg格式
- ftp协议c语言实现-linux平台