题意:

给你一堆牌,再给你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(模拟)相关推荐

  1. hdu 2629 Identity Card (字符串解析模拟题)

    这题是一个字符串模拟水题,给12级学弟学妹们找找自信的,嘿嘿; 题目意思就是要你讲身份证的上的省份和生日解析出来输出就可以了: http://acm.hdu.edu.cn/showproblem.ph ...

  2. 【HDU】4706 Children's Day(模拟)

    http://acm.hdu.edu.cn/showproblem.php?pid=4706 该题没有输入,直接输出不同形状大小的N,在输出不同形状N的时候是要用到26个字母,并且是循环输出 #inc ...

  3. HDU Problem - 6396 Swordsman(优先队列,模拟)

    题目链接 Problem Description Lawson is a magic swordsman with kkk kinds of magic attributes v1,v2,v3,-,v ...

  4. HDU多校5 - 6816 Boring Game(模拟)

    题目链接:点击查看 题目大意:给出 n 张叠在一起的纸,现在将其连续从左向右折叠 k 次,再从上到下标上序号,问展开后的序号是怎么样的 题目分析:比赛时一直在找规律,确实是有规律,但是我找不到..去请 ...

  5. HDU - 1547 Bubble Shooter(dfs+连通块+模拟)

    题目链接:点击查看 题目大意:模拟泡泡枪游戏,问当击破指定位置的泡泡时,能有多少个泡泡同时爆炸? 题目分析:一个中规中矩的连通块问题,只不过在向四周扩散的时候需要注意的是,奇数行和偶数行的方向有点不一 ...

  6. HDU 4740 The Donkey of Gui Zhou (模拟)

    由于一开始考虑的很不周到,找到很多bug.....越改越长,不忍直视. 不是写模拟的料...................... 反正撞墙或者碰到已经走过的点就会转向,转向后还碰到这两种情况就会傻站 ...

  7. HDU 4884 —— TIANKENG’s rice shop(模拟)

    题目:TIANKENG's rice shop 题意,就是有N种炒饭,每次炒的时间是t分钟,每次最多炒k份,然后按照进店的顺序给出m个顾客的信息,进店时间,炒饭的编号以及份数.然后要输出每个顾客离开的 ...

  8. 【HDU - 1013 】Digital Roots (大数模拟)

    题干: The digital root of a positive integer is found by summing the digits of the integer. If the res ...

  9. 【HDU - 1237】简单计算器 (栈模拟)

    题干: 读入一个只包含 +, -, *, / 的非负整数计算表达式,计算该表达式的值. Input 测试输入包含若干测试用例,每个测试用例占一行,每行不超过200个字符,整数和运算符之间用一个空格分隔 ...

最新文章

  1. 网络推广外包专员浅析为何网站网络推广外包中有排名却没有转化率
  2. 流水线问题--计算机体系结构
  3. Odoo10教程---模块化一:新建一个模块及基本视图
  4. Codeforces 439C Devu and Partitioning of the Array(模拟)
  5. Spark RDD的运行机制 工作节点分布关系
  6. android 获取程序名,Android_Android获取应用程序名称(ApplicationName)示例,MainActivity如下: 复制代码 代码 - phpStudy...
  7. Servlet教程第4讲笔记
  8. linux 执行程序时,提示not found问题分析
  9. 用户‘Sa’登录失败原因
  10. 成都Uber优步司机奖励政策(3月4日)
  11. 李维:我的回忆和一些有趣的事(About Borland)(转载)
  12. php选课实验成品_PHP基于B/S模式下的学生选课管理系统、源码分享
  13. LVGL lv_msgbox消息对话框(22)
  14. 阿里云数据库(RDS)是什么,与传统数据库有什么区别?
  15. nginx+域名配置
  16. 进程、线程、程序的区别
  17. Forexclub:中东这两个国家是如何开发新能源并使其经济多样化
  18. ShareSDK的使用
  19. Windows Server R2 2008 服务器总是自动关机
  20. html中用上级目录,html如何表示上级目录

热门文章

  1. mysql入门视频 吾_学习猿地-全网最新版本MySQL8全套视频教程(学完这个课 MySQL 就精通了)...
  2. PB处理BLOB类型的方法
  3. XStream入门示例
  4. 第 1 章 Logical Volume Manager (LVM)
  5. 简单交错序列前N项和
  6. java 管道设计_设计模式——管道模式
  7. SAP S4 HANA 安装部署记事七.SAP S4 ON HANA 的部署准备
  8. dw如何制作图片自动切换效果_如何在Dreamweaver中制作图片切换的效果?
  9. 阿德莱德大学计算机科学学士学分,留学360:阿德莱德大学软件工程计算机科学学士专业简析...
  10. 阿德莱德大学语言班成绩为C,阿德莱德大学语言班 雅思多少